Create a new file system loader.

@param {String} dir - the folder containing blog posts
@param {Object} options (optional)
489257
function FileSystemLoader(dir, options) {
    this.dir = dir.replace(/\/$/, '');
    this.options = options || (options = {});
    this.posts = [];
    this.files = {};
    this.ignore = {};
    var self = this;
    (options.ignore || FileSystemLoader.ignore).forEach(function (file) {
        self.ignore[file] = true;
    });
    process.nextTick(function () {
        self.loadPosts();
    });
}
896460
function mkdirs(dir) {
  return new Promise((resolve, reject) => {
    FS.ensureDir(dir, err => {
      err ? reject(err) : resolve(dir);
    })
  });
}
1362931
function loadFile(name, dir, options) {
  var pathname = path.normalize(path.join(options.prefix, name));
  var obj = {};
  var filename = (obj.path = path.join(dir, name));
  var stats = fs.statSync(filename);
  var buffer = fs.readFileSync(filename);

  obj.cacheControl = options.cacheControl;
  obj.maxAge = obj.maxAge ? obj.maxAge : options.maxAge || 0;
  obj.type = obj.mime = mime.lookup(pathname) || "application/octet-stream";
  obj.mtime = stats.mtime;
  obj.length = stats.size;
  obj.md5 = crypto.createHash("md5").update(buffer).digest("base64");

  debug("file: " + JSON.stringify(obj, null, 2));
  if (options.buffer) obj.buffer = buffer;

  buffer = null;
  return obj;
}
447773
function mkdir(dirname, options = {}) {
  if (fs.existsSync(dirname)) return;
  assert.equal(typeof dirname, 'string', 'expected dirname to be a string');
  let opts = Object.assign({ cwd: process.cwd(), fs }, options);
  let mode = opts.mode || 0o777 & ~process.umask();
  let segs = path.relative(opts.cwd, dirname).split(path.sep);
  let make = dir => !exists(dir, opts) && fs.mkdirSync(dir, mode);
  for (let i = 0; i <= segs.length; i++) {
    try {
      make((dirname = path.join(opts.cwd, ...segs.slice(0, i))));
    } catch (err) {
      handleError(dirname, opts)(err);
    }
  }
  return dirname;
}
328028
function (options, callback) {
  options.logger('Creating temporary directory')

  async.waterfall([
    async.apply(temp.mkdir, 'electron-'),
    function (dir, callback) {
      dir = path.join(dir, options.id + '_' + options.version + '_' + options.arch)
      fs.ensureDir(dir, callback)
    }
  ], function (err, dir) {
    callback(err && new Error('Error creating temporary directory: ' + (err.message || err)), dir)
  })
}
1350158
function emptyDir(dir) {
  return new Promise((resolve, reject) => {
    FS.emptyDir(dir, err => {
      err ? reject(err) : resolve(dir);
    })
  });
}
989769
function checkForChangedFolders(dir) {
    var fileList = fs.readdirSync(dir);
    for (var i = 0; i < fileList.length; i++) {
        if (!fs.existsSync(dir+fileList[i])) { continue; }
        var dirStat;
        try {
            dirStat = fs.statSync(dir + fileList[i]);
        } catch (e) {
            // This means the file disappeared between the exists and us stating the file.
            continue;
        }
        if (dirStat.isDirectory()) {
            if (!watchingFolders[dir + fileList[i]]) {
                console.log("Adding new directory to watch: ", dir + fileList[i]);
                setupWatchers(dir + fileList[i]);
            }
        }
    }
}
955444
function (path) { // implement recursion http://stackoverflow.com/questions/13696148/node-js-create-folder-or-use-existing#24311711
  try {
    fs.mkdirSync(path);
  } catch(e) {
    // if ( e.code != 'EEXIST' ) throw e;
	if ( e.code != 'EEXIST' ) console.log(e);
  }
}
302494
function addAllFilesAndSubdirectories(dir, doneCallback) {
            FileSystem.resolve(dir, function (err, directory) {
                function visitor(entry) {
                    if (entry.isFile) {
                        if (!isFileExcluded(entry)) { // ignore .dotfiles and non-.js files
                            addFilesToTern([entry.fullPath]);
                        }
                    } else {
                        return !isDirectoryExcluded(entry.fullPath) &&
                            entry.name.indexOf(".") !== 0 &&
                            !stopAddingFiles;
                    }
                }

                if (err) {
                    return;
                }

                if (dir === FileSystem.getDirectoryForPath(rootTernDir)) {
                    doneCallback();
                    return;
                }

                directory.visit(visitor, doneCallback);
            });
        }
956665
function init(options) {

    var fs = require('fs');
    var path = require('path');
    var rootdir = path.dirname(require.main);
    var options = options || {
        config: require(path.join(rootdir, 'config.json')),
        root: rootdir,
        callback: function (noop) {}
    };
    var def = {};
    function ModulePaths (moduledir) {
        this.moduledir = moduledir;
    }

    ModulePaths.prototype.then = function (accept, reject) {
      var moduledir = this.moduledir;
      fs.readdir(moduledir, function (err, files) {
        if (err) reject(err);
        files.forEach(function (file) {
            var name = path.basename(file, '.js');
            def[name] = path.join(moduledir, name);
        });
        accept();
      });
    };
    var pubpath = new ModulePaths(path.join(path.dirname(module.filename), '..', 'public', 'js'));
    var prvpath = new ModulePaths(path.join(path.dirname(module.filename), '..', 'private', 'js'));

    Promise.all([pubpath, prvpath])
        .then(function () {
            var requirejs = require('requirejs');
            requirejs.config({
                baseUrl: path.join(rootdir),
                paths: def
            });

            requirejs(['loader_factory'], function (LoaderFactory) {
                var fs = require('fs');
                var config = options.config;
                config.paths.push(path.dirname(pubpath.moduledir));
                var loader = 'loader_express';
                var db = 'db_mongo';
                if (config.loader) loader = config.loader;
                if (config.db) db = config.db;

                new LoaderFactory().create(loader, db, function (loader) {
                    loader.init(config, options.callback);
                });
            });
        })
    .catch(function (err) {
        console.error('err:', err);
    });
}
887903
function doInstall(settings, destination) {
  // Create application directories if they don't exist.
  var folders = [
    destination,
    path.join(destination, '/public'),
    path.join(destination, '/extensions')
  ];
  folders.forEach(function(folder) {
    if (!fs.existsSync(folder)) {
      fs.mkdirSync(folder);
    }
  });

  // Create settings.json.
  fs.writeFileSync(path.join(destination, 'settings.json'), JSON.stringify(settings, null, '  '), {flag: 'w'});
}
588171
function (options, dir, callback) {
  if (_.isObject(options.icon)) {
    createHicolorIcon(options, dir, callback)
  } else if (options.icon) {
    createPixmapIcon(options, dir, callback)
  } else {
    callback()
  }
}
389433
function createFiles (num, dir) {
  for (var i = 0; i <= num; i++) {
    fs.writeFileSync(path.join(dir, 'test-' + i + '.txt'), String(i));
  }
}
157617
public static File createDir(String dir) {
        // create outdir
        File directory = null;
        if(dir != null) {
            directory = new File(dir);
            if(!(directory.exists() || directory.mkdir())) {
                Utils.croak("Can't find or create directory " + dir);
            }
        }
        return directory;
    }
677250
function makeDirectories(dirs, callback) {
  var mkdir = function(dir, mkCallback) {
    exec('mkdir -p ' + dir, function(err, stdout, stderr) {
      return mkCallback(err);
    });
  };

  async.forEach(dirs, mkdir, callback);
}
1739
function (options, dir, callback) {
  var applicationDir = path.join(dir, 'lib', options.id)
  options.logger('Copying application to ' + applicationDir)

  async.waterfall([
    async.apply(fs.ensureDir, applicationDir),
    async.apply(fs.copy, options.src, applicationDir)
  ], function (err) {
    callback(err && new Error('Error copying application directory: ' + (err.message || err)))
  })
}
1334168
function zipDirectory(directories, dest, callback) {
        var archive = archiver.create('zip', {gzip: false});

        // Where to write the file
        var destStream = fs.createWriteStream(dest);

        archive.on('error', function(err) {
            this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Archiving failed', err));
        });

        archive.on('entry', function(file) {
            // do nothing
        });

        destStream.on('error', function(err) {
            this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'WriteStream failed', err));
        });

        destStream.on('close', function() {
            var size = archive.pointer();
            gutil.log(PLUGIN_NAME, gutil.colors.green('Created ' + dest + ' (' + size + ' bytes)'));
            callback();
        });

        archive.pipe(destStream);

        directories.forEach(function(directory) {
            if (fs.lstatSync(directory.src).isDirectory()) {
              archive.directory(directory.src, directory.dest);
            } else {
              this.emit('error', new gutil.PluginError(PLUGIN_NAME, directory.src + ' is not a valid directory'));
              return;
            }
        });

        archive.finalize();
    }