pakmanaged.js
function copyFileSync(srcFile, destFile) {
      if (!fs.existsSync(srcFile))
        common.error('copyFileSync: no such file or directory: ' + srcFile);
    
      var BUF_LENGTH = 64*1024,
          buf = new Buffer(BUF_LENGTH),
          bytesRead = BUF_LENGTH,
          pos = 0,
          fdr = null,
          fdw = null;
    
      try {
        fdr = fs.openSync(srcFile, 'r');
      } catch(e) {
        common.error('copyFileSync: could not read src file ('+srcFile+')');
      }
    
      try {
        fdw = fs.openSync(destFile, 'w');
      } catch(e) {
        common.error('copyFileSync: could not write to dest file (code='+e.code+'):'+destFile);
      }
    
      while (bytesRead === BUF_LENGTH) {
        bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
        fs.writeSync(fdw, buf, 0, bytesRead);
        pos += bytesRead;
      }
    
      fs.closeSync(fdr);
      fs.closeSync(fdw);
    
      fs.chmodSync(destFile, fs.statSync(srcFile).mode);
    }
function copyFileSync(srcFile, destFile) {
      if (!fs.existsSync(srcFile))
        common.error('copyFileSync: no such file or directory: ' + srcFile);
    
      var BUF_LENGTH = 64*1024,
          buf = new Buffer(BUF_LENGTH),
          bytesRead = BUF_LENGTH,
          pos = 0,
          fdr = null,
          fdw = null;
    
      try {
        fdr = fs.openSync(srcFile, 'r');
      } catch(e) {
        common.error('copyFileSync: could not read src file ('+srcFile+')');
      }
    
      try {
        fdw = fs.openSync(destFile, 'w');
      } catch(e) {
        common.error('copyFileSync: could not write to dest file (code='+e.code+'):'+destFile);
      }
    
      while (bytesRead === BUF_LENGTH) {
        bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
        fs.writeSync(fdw, buf, 0, bytesRead);
        pos += bytesRead;
      }
    
      fs.closeSync(fdr);
      fs.closeSync(fdw);
    
      fs.chmodSync(destFile, fs.statSync(srcFile).mode);
    }
Buffered file copy, synchronous (Using readFileSync() + writeFileSync() could easily cause a memory overflow with large files)