Create `SCons.Node.FS.File`
517409
def File(self, name, directory=None, create=1):
        
        return self._create_node(name, self.env.fs.File, directory, create)
283487
function copySchemaFiles() {
    const resolvedSrcSchemaPaths = path.resolve(rootDir, srcSchemaPaths);

    glob(resolvedSrcSchemaPaths, void(0), function(error, files) {
        files.forEach((filePath) => {
        const destSchemaPath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir);
            fs.copyFileSync(filePath, destSchemaPath);
        });
    });
}
383743
def add_new_file(self, node):
        

        if self.__script_editor.model.is_authoring_node(node):
            return self.__script_editor.new_file()

        file, state = QInputDialog.getText(self, "Add File", "Enter your new file name:")
        if not state:
            return False

        if node.family in ("Project", "Directory"):
            directory = node.path
        elif node.family == "File":
            directory = os.path.dirname(node.path)

        # file = foundations.strings.to_string(file)
        if not file in os.listdir(directory):
            file = os.path.join(directory, file)
            LOGGER.info("{0} | Adding '{1}' file!".format(self.__class__.__name__, file))
            open(file, "w").close()
        else:
            self.__raise_file_system_exception(file, directory)
        return True
546604
def create_file_manage_actions(self, fnames):
        """"""
        only_files = all([osp.isfile(_fn) for _fn in fnames])
        only_modules = all([osp.splitext(_fn)[1] in ('.py', '.pyw', '.ipy')
                            for _fn in fnames])
        only_notebooks = all([osp.splitext(_fn)[1] == '.ipynb'
                              for _fn in fnames])
        only_valid = all([encoding.is_text_file(_fn) for _fn in fnames])
        run_action = create_action(self, _("Run"), icon=ima.icon('run'),
                                   triggered=self.run)
        edit_action = create_action(self, _("Edit"), icon=ima.icon('edit'),
                                    triggered=self.clicked)
        move_action = create_action(self, _("Move..."),
                                    icon="move.png",
                                    triggered=self.move)
        delete_action = create_action(self, _("Delete..."),
                                      icon=ima.icon('editdelete'),
                                      triggered=self.delete)
        rename_action = create_action(self, _("Rename..."),
                                      icon=ima.icon('rename'),
                                      triggered=self.rename)
        open_external_action = create_action(self, _("Open With OS"), 
                                             triggered=self.open_external)
        ipynb_convert_action = create_action(self, _("Convert to Python script"),
                                             icon=ima.icon('python'),
                                             triggered=self.convert_notebooks)
        copy_file_clipboard_action = (
            create_action(self, _("Copy"),
                          QKeySequence(get_shortcut('explorer', 'copy file')),
                          icon=ima.icon('editcopy'),
                          triggered=self.copy_file_clipboard))
        save_file_clipboard_action = (
            create_action(self, _("Paste"),
                          QKeySequence(get_shortcut('explorer', 'paste file')),
                          icon=ima.icon('editpaste'),
                          triggered=self.save_file_clipboard))
        copy_absolute_path_action = (
            create_action(self, _("Copy Absolute Path"), QKeySequence(
                get_shortcut('explorer', 'copy absolute path')),
                          triggered=self.copy_absolute_path))
        copy_relative_path_action = (
            create_action(self, _("Copy Relative Path"), QKeySequence(
                get_shortcut('explorer', 'copy relative path')),
                          triggered=self.copy_relative_path))
        
        actions = []
        if only_modules:
            actions.append(run_action)
        if only_valid and only_files:
            actions.append(edit_action)
        
        if sys.platform == 'darwin':
            text=_("Show in Finder")
        else:
            text=_("Show in Folder")
        external_fileexp_action = create_action(self, text, 
                                triggered=self.show_in_external_file_explorer)        
        actions += [delete_action, rename_action]
        basedir = fixpath(osp.dirname(fnames[0]))
        if all([fixpath(osp.dirname(_fn)) == basedir for _fn in fnames]):
            actions.append(move_action)
        actions += [None]
        actions += [copy_file_clipboard_action, save_file_clipboard_action,
                    copy_absolute_path_action, copy_relative_path_action]
        if not QApplication.clipboard().mimeData().hasUrls():
            save_file_clipboard_action.setDisabled(True)
        actions += [None]
        if only_files:
            actions.append(open_external_action)
        actions.append(external_fileexp_action)
        actions.append([None])
        if only_notebooks and nbexporter is not None:
            actions.append(ipynb_convert_action)

        # VCS support is quite limited for now, so we are enabling the VCS
        # related actions only when a single file/folder is selected:
        dirname = fnames[0] if osp.isdir(fnames[0]) else osp.dirname(fnames[0])
        if len(fnames) == 1 and vcs.is_vcs_repository(dirname):
            commit_slot = lambda : self.vcs_command([dirname], 'commit')
            browse_slot = lambda : self.vcs_command([dirname], 'browse')
            vcs_ci = create_action(self, _("Commit"),
                                   icon=ima.icon('vcs_commit'),
                                   triggered=commit_slot)
            vcs_log = create_action(self, _("Browse repository"),
                                    icon=ima.icon('vcs_browse'),
                                    triggered=browse_slot)
            actions += [None, vcs_ci, vcs_log]

        return actions
1307581
def build(self, **kw):
        """"""
        global MkdirBuilder
        if self.builder is not MkdirBuilder:
            SCons.Node.Node.build(self, **kw)
1193407
function createOutputFolder(next) {
    var defPath         = path.join(getConfig('output.folder'), 'definition-files'),
        defPathCustom   = path.join(getConfig('output.folder'), 'definition-files-custom');

    fs.remove(defPath, function (err) {
        if (err) { next(err); }
        fs.createFile(path.join(defPath, '_Dont_add_or_edit_any_files'), function (err) {
            if (err) { next(err); }
            fs.mkdirs(defPathCustom, function (err) {
                if (err) { next(err); }
                next(null);
            });
        });
    });
}
1266117
def sf(f, dirpath, jottapath):
    """"""
    log.debug('Create SyncFile from %s', repr(f))
    log.debug('Got encoded filename %r, joining with dirpath %r', _encode_filename_to_filesystem(f), dirpath)
    return SyncFile(localpath=os.path.join(dirpath, _encode_filename_to_filesystem(f)),
                  jottapath=posixpath.join(_decode_filename_to_unicode(jottapath), _decode_filename_to_unicode(f)))
1317050
function makeJobFile(config) {
  var job = {"espruino":{}};
  // assign commandline values
  for (var key in args) {
    switch (key) {
      case 'job': // remove job itself, and others set internally from the results
      case 'espruinoPrefix':
      case 'espruinoPostfix':
        break;
      default: job[key] = args[key];  // otherwise just output each key: value
    }
    // write fields of Espruino.Config passed as config
    for (var k in config) { if (typeof config[k]!=='function') job.espruino[k] = config[k]; };
  }
  // name job file same as code file with json ending or default and save.
  var jobFile = isNextValidJS(args.file) ? args.file.slice(0,args.file.lastIndexOf('.'))+'.json' : "job.json";

  if (!fs.existsSync(jobFile)) {
    log("Creating job file "+JSON.stringify(jobFile));
    fs.writeFileSync(jobFile,JSON.stringify(job,null,2),{encoding:"utf8"});
  } else
    log("WARNING: File "+JSON.stringify(jobFile)+" already exists - not overwriting.");
}
760644
function createFiles (num, dir) {
  for (var i = 0; i < num; i++) {
    grunt.file.write(path.join(dir, 'test-' + i + '.js'), 'var test = ' + i + ';');
  }
}
359246
function( options, callback ) {
            var me = this;
            var error = function(e) { fail(e); if ( callback ) me.fn( me.name, callback ).call( me, me ); };
            requestFileSystem( (options.storage === 'TEMPORARY' ? TEMPORARY : PERSISTENT), (options.size || 1024*1024*1024), function( fs ) {
                fs.root.getDirectory( options.name, {create:true}, function( directory ) {
                    filesystems[options.name] = directory;
                    if ( callback ) me.fn( me.name, callback ).call( me, me );
                }, error );
            }, error );
        }
828532
function createPackageFile(content) {
    // todo in the rootfolder
    createFile({
        name: constants.INCLUDE_FILE,
        source: `${JSON.stringify(content)}\n`,
    });
}
889985
function createNode (options, callback) {
  if (typeof options === 'function') {
    callback = options
    options = {}
  }

  options.path = options.path || '/tmp/ipfs' + Math.random()

  const node = new IPFS({
    repo: options.path
  })

  node.on('start', () => callback(null, node))
}
390791
def _create(self):
        """"""
        listDirs = []
        parent = self
        while parent:
            if parent.exists():
                break
            listDirs.append(parent)
            p = parent.up()
            if p is None:
                # Don't use while: - else: for this condition because
                # if so, then parent is None and has no .path attribute.
                raise SCons.Errors.StopError(parent._path)
            parent = p
        listDirs.reverse()
        for dirnode in listDirs:
            try:
                # Don't call dirnode.build(), call the base Node method
                # directly because we definitely *must* create this
                # directory.  The dirnode.build() method will suppress
                # the build if it's the default builder.
                SCons.Node.Node.build(dirnode)
                dirnode.get_executor().nullify()
                # The build() action may or may not have actually
                # created the directory, depending on whether the -n
                # option was used or not.  Delete the _exists and
                # _rexists attributes so they can be reevaluated.
                dirnode.clear()
            except OSError:
                pass
855793
function(filename, gnaFolder, content, callback){
        if ( fs.existsSync(filename) ) {
            fs.unlinkSync(filename)
        }
        fs.appendFile(
            filename,
            JSON.stringify(content, null, '\t'),
            null,
            function(err){
                if (err) {
                    //logger.error('gina', 'UTILS:CONFIG:ERR:2', err, __stack);
                    console.error('`Error on while calling createContent()`: ' + err.stack||err.message);
                    callback(err)
                } else {
                    setTimeout(function(){
                        callback(err)
                    }, 1000)
                }
            }//EO function
        )//EO fs.appendFile
    }
85758
function appendToFile(fileContent, filePath) {
  return new Promise((resolve, reject) => {
    fs.appendFile(filePath, fileContent, 'utf8', (err) => {
      if (err) {
        reject(err);
      } else {
        resolve(filePath);
      }
    });
  });
}
1024809
function writeFile(filepath, data, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }

  if (!Buffer.isBuffer(data)) {
    return callback(new TypeError('Data must be a Buffer'));
  }

  if (!options) {
    options = {};
  }

  // Default the same as node
  var mode = options.mode || constants.DEFAULT_FILE_MODE;
  var flags = options.flags || 'w';
  var position = APPEND_MODE_REGEXP.test(flags) ? null : 0;

  fs.open(filepath, flags, mode, onOpen);

  function onOpen(openErr, fd) {
    if (openErr) {
      return onComplete(openErr);
    }

    fs.write(fd, data, 0, data.length, position, onComplete);

    function onComplete(writeErr) {
      callback(writeErr, fd);
    }
  }
}
726610
async function generateNodeSource() {
  const sourceText = await fs.readFile(sourceFile, 'utf8');

  // Parse index.d.ts. A dummy filename is required but it doesn't create a
  // file.
  let typescriptSourceFile = typescript.createSourceFile(
    'temp.d.ts',
    sourceText,
    typescript.ScriptTarget.ES2015,
    /*setParentNodes */ false
  );

  /**
   * Typescript transformer function. Removes nodes tagged with @webonly.
   */
  const removeWebOnlyNodes = context => rootNode => {
    function visit(node) {
      if (
        node.jsDoc &&
        node.jsDoc.some(
          item =>
            item.tags &&
            item.tags.some(tag => tag.tagName.escapedText === 'webonly')
        )
      ) {
        return null;
      }
      return typescript.visitEachChild(node, visit, context);
    }
    return typescript.visitNode(rootNode, visit);
  };

  // Use above transformer on source AST to remove nodes tagged with @webonly.
  const result = typescript.transform(typescriptSourceFile, [
    removeWebOnlyNodes
  ]);

  // Convert transformed AST to text and write to file.
  const printer = typescript.createPrinter();
  return fs.writeFile(
    tempNodeSourcePath,
    printer.printFile(result.transformed[0])
  );
}