Creates a new instance of AviGlitch::Base, open the file and
 make it ready to manipulate.
 It requires +path+ as Pathname.

 Outputs the glitched file to +path+, and close the file.
348194
def output path, do_file_close = true
      FileUtils.cp @file.path, path
      close if do_file_close
      self
    end
79486
def create(path)
      self.destination_root = path

      copy_file(".gitignore")
      copy_file("config.ru")
      copy_file("Gemfile")
      copy_file("Procfile")
      copy_file("README.md")

      copy_content
      copy_themes
    end
58872
def open(cls, path='', encoding=None, error_handling=ERROR_PASS):
        
        source_file, encoding = cls._open_unicode_file(path, claimed_encoding=encoding)
        new_file = cls(path=path, encoding=encoding)
        new_file.read(source_file, error_handling=error_handling)
        source_file.close()
        return new_file
184584
def regenerateFile(srcFile, pathComponents, sourceType, makeBackup)
      #puts "regenerateFile, srcFile = #{srcFile}, sourceType = #{sourceType.inspect}"
      outFile = File.join(@sourceTypeDirs[@oppositeSourceType[sourceType]], File.join(pathComponents))
      #puts " outFile = #{outFile}"
      outFileDir = File.dirname(outFile)
      if !File.exists?(outFileDir)
        if sourceType == :output
          raise "Cannot create missing source directory #{outFileDir} - please do so manually if required"
        end
        ensureDirectoryExists(outFileDir)
      end
      if sourceType == :output
        regenerateSourceFromOutput(srcFile, pathComponents)
      elsif sourceType == :source
        regenerateFileFromSource(srcFile, pathComponents, makeBackup)
      end
    end
938956
def new_from_files(self, basepath, basename, repo, \
                    bohrs=False, \
                    software=_E_SW.ORCA, \
                    repo_clobber=False, **kwargs):
        

        # Imports
        import os
        from os import path as osp
        from ..xyz import OpanXYZ as OX
        from ..grad import OrcaEngrad as OE
        from ..hess import OrcaHess as OH
        from .repo import OpanAnharmRepo as OR
        from ..const import EnumDispDirection as E_DDir, EnumFileType as E_FT
        from ..const import EnumSoftware as E_SW
        from ..const import DEF
        from ..error import AnharmError as ANHErr

##        # Store working directory for restore?
##        prev_dir = os.getcwd()

        # Complain if anything is already bound
        if not self.w_xyz == None:
            raise ANHErr(ANHErr.STATUS,
                    "XYZ object is already bound",
                    "")
        ## end if
        if not self.w_grad == None:
            raise ANHErr(ANHErr.STATUS,
                    "GRAD object is already bound",
                    "")
        ## end if
        if not self.w_hess == None:
            raise ANHErr(ANHErr.STATUS,
                    "HESS object is already bound",
                    "")
        ## end if
        if not self.repo == None:
            raise ANHErr(ANHErr.STATUS,
                    "Repository object is already bound",
                    "")
        ## end if

        # RESUME: vpt2--factor for loading from different software pkgs

        # Load the three data files
        self.w_xyz = OX( osp.join(basepath, \
                basename + osp.extsep + xyz_ext) )
        self.w_grad = OE( osp.join(basepath, \
                basename + osp.extsep + engrad_ext), \
                0, E_DDir.NO_DISP, 0.0 )
        self.w_hess = OH( osp.join(basepath, \
                basename + osp.extsep + hess_ext), \
                0, E_DDir.NO_DISP, 0.0 )

        # Only accept new repos for now
        if not isinstance(repo, str):
            raise TypeError("Must create new repository when loading " +
                    "a new dataset.")
        ## end if

        # Repo is string, treat as filename and try to load
        # Check if it's a complete path
        # If it's a relative path, prepend the basepath
        if osp.split(repo[0]) > 0 and not osp.isabs(repo):
            repo = osp.join(basepath, repo)
        ## end if

        # Complain if it's a directory
        if osp.isdir(repo):
            raise IOError("Cannot bind repository -- specified " +
                    "location is a directory")
        ## end if

        # If file exists ...
        if osp.isfile(repo):
                # Depending on clobber, either delete existing or raise error
                if repo_clobber:
                    # Clobber old repo
                    os.remove(repo)
                else:
                    # Raise error
                    raise IOError("Target repository file exists and " +
                            "clobber is disabled.")
                ## end if
            ## end if

        # Should be good to create the repo
        self.repo = OR(repo)
728782
def create
      ImageScratch.where(ownable: current_user).destroy_all

      # The persistence code that follows is suboptimal.  I'm a bit tired
      # right now.  Don't see it. Needs to be fixed.  Issue should be raised.
      # TODO Raise issue here.
      ActiveRecord::Base.transaction do
        @scratch = ImageScratch.new(ownable: current_user);
        authorize! :create, @scratch
        @scratch.save!
        @scratch.image_version = ImageVersion.new(image: image_scratch_params[:image], ownable: @scratch);
        @scratch.save!
      end

    end
57990
def add_file(filename, parent = @root_iter)
      my_path = File.dirname(filename)
      model.each do |model, path, iter|
        return if iter[id(:path)] == filename # duplicate
        parent = iter if iter[id(:path)] == my_path
      end
      fn = filename.gsub("\\", "/")
      parent[id(:empty)] = false unless parent.nil?
      child = add_row(parent)
      child[:pix] = @icons.get_icon(File.directory?(fn) ? "x.folder" : fn)   if @icons
      child[:file_name] = File.basename(fn)
      child[:path] = fn
      if File.directory?(fn)
        child[:sort_on] = "0" + child[:file_name]
        child[:empty] = true
        add_row(child) # dummy record so expander appears  
      else
        child[id(:sort_on)] = "1" + child[id(:file_name)]      
      end
      return child
    end
840124
function openFile(file) {
      var edit;
      if (!editor || gui) {
        open(file);
      } else {
        edit = spawn(editor, [file], {stdio: 'inherit'});
        edit.on('exit', process.exit);
      }
    }
8705
def anonymize_path(path)
      if @tags.length > 0
        prepare_anonymization
        files = DICOM.load_files(path)
        logger.info("#{files.length} DICOM files have been prepared for anonymization.")
        files.each do |f|
          dcm = anonymize_file(f)
          write(dcm)
        end
      else
        logger.warn("No tags have been selected for anonymization. Aborting anonymization.")
      end
      # Save the audit trail (if used):
      @audit_trail.write(@audit_trail_file) if @audit_trail
      logger.info("Anonymization complete.")
    end
963863
def create_gemspec(file=nil)
      file = gemspec if !file
      #require 'gemdo/gemspec'
      yaml = project.to_gemspec.to_yaml
      File.open(file, 'w') do |f|
        f << yaml
      end
      status File.basename(file) + " updated."
      return file
    end
668345
def execute(output: $stdout, errors: $stderr)
      if empty_name?
        output.puts 'No name given'
        return false
      end
      result = run "find #{@path} #{type} -name '#{@name}'" do |_out, err|
        errors << err if err
      end
      # The following line makes the output into something readable
      #
      # Before the output would have looked like this:
      ## ./lib/my_file.rb
      ## ./lib/folder/my_file.rb
      #
      # Whereas it will now look like this:
      ## ./lib/my_file.rbi NEW_NAME=> ./lib/my_file.rb
      ## ./lib/folder/my_file.rb NEW_NAME=> ./lib/folder/my_file.rb
      #
      # Making it more obvious that the original path is on the left
      # and the path to edit is on the right
      @result = result.out.split("\n").map { |path| "#{path} NEW_NAME=> #{path}" }.join("\n")
    rescue TTY::Command::ExitError => error
      output.puts error
    end
293521
protected function createPath(string $sPath): BaseMaker
    {
        if (!is_dir($sPath)) {
            if (!@mkdir($sPath, self::FILE_PERMISSION, true)) {
                throw new DoesNotExistException('Path "' . $sPath . '" does not exist and could not be created');
            }
        }

        if (!is_writable($sPath)) {
            throw new IsNotWritableException('Path "' . $sPath . '" exists, but is not writable');
        }

        return $this;
    }
996582
def create_new_file(self, current_path, title, filters, create_func):
        """"""
        if current_path is None:
            current_path = ''
        if osp.isfile(current_path):
            current_path = osp.dirname(current_path)
        self.redirect_stdio.emit(False)
        fname, _selfilter = getsavefilename(self, title, current_path, filters)
        self.redirect_stdio.emit(True)
        if fname:
            try:
                create_func(fname)
                return fname
            except EnvironmentError as error:
                QMessageBox.critical(self, _("New file"),
                                     _("<b>Unable to create file <i>%s</i>"
                                       "</b><br><br>Error message:<br>%s"
                                       ) % (fname, to_text_string(error)))
1213028
def _OpenFileObject(self, path_spec):
    
    if not path_spec.HasParent():
      raise errors.PathSpecError(
          'Unsupported path specification without parent.')

    file_object = resolver.Resolver.OpenFileObject(
        path_spec.parent, resolver_context=self._resolver_context)

    vhdi_file = pyvhdi.file()
    vhdi_file.open_file_object(file_object)

    if vhdi_file.parent_identifier:
      file_system = resolver.Resolver.OpenFileSystem(
          path_spec.parent, resolver_context=self._resolver_context)

      try:
        self._OpenParentFile(file_system, path_spec.parent, vhdi_file)
      finally:
        file_system.Close()

    self._sub_file_objects.append(file_object)

    self._parent_vhdi_files.reverse()
    self._sub_file_objects.reverse()

    return vhdi_file
247494
def make_runfile(name=nil)
      name = 'Runfile' if name.nil?
      template = File.expand_path("../templates/Runfile", __FILE__)
      name += ".runfile" unless name == 'Runfile'
      dest = "#{Dir.pwd}/#{name}"
      begin
        File.write(dest, File.read(template))
        puts "#{name} created."
      rescue => e
        abort "Failed creating #{name}\n#{e.message}"
      end
    end
459332
def _resolve(cls, path, factory_file):
        
        variables = {}

        name = factory_file
        factory_file = os.path.join(path, factory_file)

        with open(factory_file) as fh:
            exec(fh.read(), {}, variables)

        klass = variables[inflection.camelize(name)]

        instance = klass()

        return instance
1070436
def open
      file_name = File.join(@db_dir, 'database.blobs')
      new_db_created = false
      begin
        if File.exist?(file_name)
          @f = File.open(file_name, 'rb+')
        else
          PEROBS.log.info "New FlatFile database '#{file_name}' created"
          @f = File.open(file_name, 'wb+')
          new_db_created = true
        end
      rescue IOError => e
        PEROBS.log.fatal "Cannot open FlatFile database #{file_name}: " +
          e.message
      end
      unless @f.flock(File::LOCK_NB | File::LOCK_EX)
        PEROBS.log.fatal "FlatFile database '#{file_name}' is locked by " +
          "another process"
      end
      @f.sync = true

      open_index_files(!new_db_created)
    end