Location specific PDF document requirement
Copies the file which is passed to it, with
the generated name
431646
public function copyWithFile($object, $file) {
        if ($object instanceof \Puzzlout\Framework\Interfaces\IDocument) {
            $object->setFilename($this->GetFileNameToSaveInDatabase($file));
            $fileExists = \Puzzlout\Framework\Core\DirectoryManager::FileExists($this->GetUploadDirectory($object) . "/" . $object->Filename());
            $extensions = $object->ValidExtensions();
            if (is_array($extensions)) {
                $validExtension = $this->CheckExtension($file, $extensions);
            } else {
                $validExtension = true;
            }
            if (!$fileExists && $validExtension) {
                \Puzzlout\Framework\Core\DirectoryManager::CreateDirectory($this->GetUploadDirectory($object));
                $object->setContentSize($this->GetSizeInKb($file));
                $object->setContentType($this->GetExtension($file));

                //LEt's copy the file
                if (copy($file['tmp_name'], $this->GetUploadDirectory($object) . '/' . $object->Filename())) {
                    return parent::add($object);
                }
            } else {
                return -1;
            }
        }
    }
890927
def copy(self, path_patterns, symbolic_link=False, root=None,
             conflicts='fail'):
        '''  '''
        new_filename = build_path(self.entities, path_patterns)
        if not new_filename:
            return None

        if new_filename[-1] == os.sep:
            new_filename += self.filename

        if isabs(self.path) or root is None:
            path = self.path
        else:
            path = join(root, self.path)

        if not exists(path):
            raise ValueError("Target filename to copy/symlink (%s) doesn't "
                             "exist." % path)

        if symbolic_link:
            contents = None
            link_to = path
        else:
            with open(path, 'r') as f:
                contents = f.read()
            link_to = None

        write_contents_to_file(new_filename, contents=contents,
                               link_to=link_to, content_mode='text', root=root,
                               conflicts=conflicts)
162752
def copy(doc, dest, src):
    

    return Target(doc).copy(dest, src).document
1000133
function copySourceContent(filename) {
    var content = consumer.sourceContentFor(filename);
    if (content) {
      generator.setSourceContent(filename, content);
    }
  }
62435
function copyFile (oldName, newName) {
    let contents = fs.readFileSync (oldName, 'utf8')
    fs.truncateSync (newName)
    fs.writeFileSync (newName, contents)
}
549047
public static void actionCopy(PageContext pageContext, lucee.runtime.security.SecurityManager securityManager, Resource source, String strDestination, int nameconflict,
	    String serverPassword, Object acl, int mode, String attributes) throws PageException {
	if (nameconflict == NAMECONFLICT_UNDEFINED) nameconflict = NAMECONFLICT_OVERWRITE;

	if (source == null) throw new ApplicationException("attribute source is not defined for tag file");
	if (StringUtil.isEmpty(strDestination)) throw new ApplicationException("attribute destination is not defined for tag file");

	Resource destination = toDestination(pageContext, strDestination, source);

	securityManager.checkFileLocation(pageContext.getConfig(), source, serverPassword);
	securityManager.checkFileLocation(pageContext.getConfig(), destination, serverPassword);

	// source
	if (!source.exists()) throw new ApplicationException("source file [" + source.toString() + "] doesn't exist");
	else if (!source.isFile()) throw new ApplicationException("source file [" + source.toString() + "] is not a file");
	else if (!source.canRead()) throw new ApplicationException("no access to source file [" + source.toString() + "]");

	// destination
	if (destination.isDirectory()) destination = destination.getRealResource(source.getName());
	if (destination.exists()) {
	    // SKIP
	    if (nameconflict == NAMECONFLICT_SKIP) return;
	    // SKIP
	    else if (nameconflict == NAMECONFLICT_OVERWRITE) destination.delete();
	    // MAKEUNIQUE
	    else if (nameconflict == NAMECONFLICT_MAKEUNIQUE) destination = makeUnique(destination);
	    // ERROR
	    else throw new ApplicationException("destiniation file [" + destination.toString() + "] already exist");
	}

	setACL(pageContext, destination, acl);
	try {
	    IOUtil.copy(source, destination);
	}
	catch (IOException e) {

	    ApplicationException ae = new ApplicationException("can't copy file [" + source + "] to [" + destination + "]", e.getMessage());
	    ae.setStackTrace(e.getStackTrace());
	    throw ae;
	}

	setMode(destination, mode);
	setAttributes(destination, attributes);
    }
521705
def save(self, filename, garbage=0, clean=0, deflate=0, incremental=0, ascii=0, expand=0, linear=0, pretty=0, decrypt=1):
        """"""

        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")
        if type(filename) == str:
            pass
        elif type(filename) == unicode:
            filename = filename.encode('utf8')
        else:
            raise TypeError("filename must be a string")
        if filename == self.name and not incremental:
            raise ValueError("save to original must be incremental")
        if self.pageCount < 1:
            raise ValueError("cannot save with zero pages")
        if incremental:
            if self.name != filename or self.stream:
                raise ValueError("incremental needs original file")


        return _fitz.Document_save(self, filename, garbage, clean, deflate, incremental, ascii, expand, linear, pretty, decrypt)
59335
def copy_doc(source, dest, permalink=nil)
      contents = File.open(source).read

      # Convert H1 to title and add permalink in YAML front-matter
      #
      contents.sub!(/^# (.*)$/, "#{doc_yaml('\1', permalink).strip}")

      FileUtils.mkdir_p File.dirname(dest)
      File.open(dest, 'w') {|f| f.write(contents) }
      puts "Updated #{dest} from #{source}"
    end
1285644
function copyNamedProperties(names, src, dst) {
  names.forEach(function(name) {
    const value = src[name];
    if (value !== undefined) {
      dst[name] = value;
    }
  });
}
1014085
function copyFile(source, target, copyCallback) {
    const readStream = fs.createReadStream(source);
    const writeStream = fs.createWriteStream(target);
    let done = false;

    readStream.on('error', copyDone);
    writeStream.on('error', copyDone);

    writeStream.on('close', function onWriteCb() {
        copyDone(null);
    });

    readStream.pipe(writeStream);

    /**
     * Finish copying. Reports error when needed
     * @param [error] optional error
     */
    function copyDone(error) {
        if (!done) {
            done = true;
            copyCallback(error);
        }
    }
}
1175164
def output(self, name='',dest=''):
        ""
        #Finish document if necessary
        if(self.state<3):
            self.close()
        dest=dest.upper()
        if(dest==''):
            if(name==''):
                name='doc.pdf'
                dest='I'
            else:
                dest='F'
        if dest=='I':
            print(self.buffer)
        elif dest=='D':
            print(self.buffer)
        elif dest=='F':
            #Save to local file
            f=open(name,'wb')
            if(not f):
                self.error('Unable to create output file: '+name)
            if PY3K:
                # manage binary data as latin1 until PEP461 or similar is implemented
                f.write(self.buffer.encode("latin1"))
            else:
                f.write(self.buffer)
            f.close()
        elif dest=='S':
            #Return as a string
            return self.buffer
        else:
            self.error('Incorrect output destination: '+dest)
        return ''
1287852
function copyFile(assetPath, dest, hexFolder) {

      // Copy the asset file to the hashed folder and store the mapping.
      var relativeAssetPath = stripPrefixAndNormalise(assetPath, options.srcBasePath),
          hashDir  = path.join(dest, path.dirname(relativeAssetPath), hexFolder),
          destPath = path.join(hashDir, path.basename(assetPath));

      if (options.hashType === 'file') {
        var ext = path.extname(assetPath),
            hashedFilename = path.basename(assetPath, ext) + '.' + hexFolder + ext;
        hashDir  = path.join(dest, path.dirname(relativeAssetPath));
        destPath = path.join(hashDir, hashedFilename);
      }

      var relativeDestPath = stripPrefixAndNormalise(destPath, options.destBasePath);

      grunt.file.copy(assetPath, destPath);
      assetFileMapping[relativeAssetPath] = relativeDestPath;
      grunt.log.writeln('Copied asset: ' + assetPath + ' -> ' + destPath);

      // Copy the source map file to the same hashed folder.
      var sourceMapPath = sourceMaps[assetPath];
      if (sourceMapPath) {
        var destSourceMapPath = path.join(hashDir, path.basename(sourceMapPath)),
            relativeSourceMapPath = stripPrefixAndNormalise(sourceMapPath, options.srcBasePath),
            relativeDestSourceMapPath = stripPrefixAndNormalise(destSourceMapPath, options.destBasePath);

        grunt.file.copy(sourceMapPath, destSourceMapPath);
        sourceFileMapping[relativeSourceMapPath] = relativeDestSourceMapPath;
        grunt.log.writeln('Copied source map: ' + destSourceMapPath);
      }

      if (Object.keys(assetFileMapping).length === numSourceFiles) {
        writeMappingFile();
        renameReferences();
        done();
      }
    }
856693
public static void performCopy(String filename, SarlConfiguration configuration) {
		if (filename.isEmpty()) {
			return;
		}

		try {
			final DocFile fromfile = DocFile.createFileForInput(configuration, filename);
			final DocPath path = DocPath.create(fromfile.getName());
			final DocFile toFile = DocFile.createFileForOutput(configuration, path);
			if (toFile.isSameFile(fromfile)) {
				return;
			}
			configuration.message.notice((SourcePosition) null,
					"doclet.Copying_File_0_To_File_1", //$NON-NLS-1$
					fromfile.toString(), path.getPath());
			toFile.copyFile(fromfile);
		} catch (IOException exc) {
			configuration.message.error((SourcePosition) null,
					"doclet.perform_copy_exception_encountered", //$NON-NLS-1$
					exc.toString());
			throw new DocletAbortException(exc);
		}
	}
1308394
function relativeTOC(file, parent) {
        _.each(parent.children, function(child) {
          if(child.relative) {
            var href = "";
            if(config.format != "pdf") {
              var relativeFolder = path.relative(path.dirname(file.relative), path.dirname(child.relative));
              href = path.join(relativeFolder, path.basename(child.relative))
            }
            if(child.id) {
              href += "#" + child.id;
            }
            child.href = href;
          }
          if(child.children) {
            child = relativeTOC(file, child);
          }
        });
        return parent;
      }
216211
def copy_source_files(config, pages_required=True):
  

  for path in config['additional_search_paths']:
    path = os.path.abspath(path)
    sys.path.append(path)

  # Copy all template files from the source directory into our
  # generated files directory.
  log('Started copying source files...')
  for root, dirs, files in os.walk(config['docs_dir']):
    rel_root = os.path.relpath(root, config['docs_dir'])
    for fname in files:
      dest_fname = os.path.join(config['gens_dir'], rel_root, fname)
      makedirs(os.path.dirname(dest_fname))
      shutil.copyfile(os.path.join(root, fname), dest_fname)

  if 'pages' not in config:
    if pages_required:
      raise RuntimeError('pydocmd.yml does not have defined pages!')

    return

  for page in config['pages']:
    process_pages(page, config['gens_dir'])
1031975
def setDocument(self, filename, empty=""):
        
        self._source = QUrl.fromLocalFile(filename)
        if os.path.exists(filename):
            self.viewer.setSource(self._source)
        else:
            self.viewer.setText(empty)
1369299
function createDestReadme(srcReadmePath) {
 
    const destReadmePath = srcReadmePath.replace(/(\bpackages\b)(?!.*\1)/, destDir);
    const destDirPath = path.dirname(destReadmePath);
    const srcDirPath = path.dirname(srcReadmePath);
    const srcReadmeText = fs.readFileSync(srcReadmePath).toString();

    var folderName = srcDirPath
        .split(path.sep)
        .pop();

    var lines = fs.readFileSync(srcReadmePath, 'utf-8')
        .split('\n')
        .filter(Boolean);

    var title = lines[0]
        .replace(/#/g, '')
        .replace(/FAST/g, '')
        .trim();
            
    var docusaurusHeader = 
        `---\n` + 
        `id: index\n` + 
        `title: FAST ${title}\n` + 
        `sidebar_label: ${title}\n` +
        `---\n\n`;

    createDirectory(destDirPath);

    if (dryRun) {
        if (fs.existsSync(destReadmePath)) {
            console.log(`...REPLACE readme.md in the '${folderName}' folder`);
        } else {
            console.log(`...ADD readme.md to the '${folderName}' folder`);
        }
    } else {
        try {
            fs.writeFileSync(destReadmePath, docusaurusHeader);
            fs.appendFileSync(destReadmePath, srcReadmeText);
            updatedDocsCount++;
            console.log(`...${folderName} was succesfully updated`);
        } catch (err) {
            console.log(chalk.red(err));
        }
    }

}