Create file generator.

@param string $outbox_root_path
@param string $stubbox_root_path

@return static
167439
public static function make($outbox_root_path, $stubbox_root_path)
    {
        if (!is_dir($outbox_root_path)) {
            mkdir($outbox_root_path, 0755, true);
        }

        $outbox = FilesystemFactory::local($outbox_root_path);

        $stubbox = FilesystemFactory::local($stubbox_root_path);

        $context = (object) [
            'outbox_root' => $outbox_root_path,
            'stubbox_root' => $stubbox_root_path,
            'directory' => null,
            'file' => null,
        ];

        return new static($outbox, $stubbox, $context);
    }
777134
public void setupOutputPath(String name) {
        // get stream filename generator
        IStreamFilenameGenerator generator = (IStreamFilenameGenerator) ScopeUtils.getScopeService(scope, IStreamFilenameGenerator.class, DefaultStreamFilenameGenerator.class);
        // generate file path
        String filePath = generator.generateFilename(scope, name, ".flv", GenerationType.RECORD);
        this.path = generator.resolvesToAbsolutePath() ? Paths.get(filePath) : Paths.get(System.getProperty("red5.root"), "webapps", scope.getContextPath(), filePath);
        // if append was requested, ensure the file we want to append exists (append==record)
        File appendee = getFile();
        if (IClientStream.MODE_APPEND.equals(mode) && !appendee.exists()) {
            try {
                if (appendee.createNewFile()) {
                    log.debug("New file created for appending");
                } else {
                    log.debug("Failure to create new file for appending");
                }
            } catch (IOException e) {
                log.warn("Exception creating replacement file for append", e);
            }
        }
    }
32664
def outbox_folder(self):
        
        return self.folder_constructor(parent=self, name='Outbox',
                                       folder_id=OutlookWellKnowFolderNames
                                       .OUTBOX.value)
519078
private FolderAndFile handle(final Path root, final Path relativePath, final Path path, final boolean create) throws FrameworkException {

		// identify mounted folder object
		final PropertyKey<String> mountTargetKey = StructrApp.key(Folder.class, "mountTarget");
		final Folder folder                      = StructrApp.getInstance().nodeQuery(Folder.class).and(mountTargetKey, root.toString()).getFirst();

		if (folder != null) {

			final String mountFolderPath = folder.getProperty(StructrApp.key(Folder.class, "path"));
			if (mountFolderPath != null) {

				final Path relativePathParent = relativePath.getParent();
				if (relativePathParent == null) {

					return new FolderAndFile(folder, getOrCreate(folder, path, relativePath, create));

				} else {

					final String pathRelativeToRoot = folder.getPath() + "/" + relativePathParent.toString();
					final Folder parentFolder       = FileHelper.createFolderPath(SecurityContext.getSuperUserInstance(), pathRelativeToRoot);
					final AbstractFile file         = getOrCreate(parentFolder, path, relativePath, create);

					return new FolderAndFile(folder, file);
				}

			} else {

				logger.warn("Cannot handle watch event, folder {} has no path", folder.getUuid());
			}
		}

		return null;
	}
1193113
def generateSetupFile(self, outpath='.', egg=False):
        
        outpath = os.path.abspath(outpath)
        outfile = os.path.join(outpath, 'setup.py')

        opts = {
            'name': self.name(),
            'distname': self.distributionName(),
            'version': self.version(),
            'author': self.author(),
            'author_email': self.authorEmail(),
            'keywords': self.keywords(),
            'license': self.license(),
            'brief': self.brief(),
            'description': self.description(),
            'url': self.companyUrl()
        }

        wrap_dict = lambda x: map(lambda k: "r'{0}': [{1}]".format(k[0],
                                                                   ',\n'.join(wrap_str(k[1]))),
                                  x.items())

        opts['dependencies'] = ',\n'.join(wrap_str(self.dependencies()))
        opts['classifiers'] = ',\n'.join(wrap_str(self.classifiers()))

        if os.path.isfile(self.sourcePath()):
            basepath = os.path.normpath(os.path.dirname(self.sourcePath()))
        else:
            basepath = os.path.normpath(self.sourcePath())

        self.generatePlugins(basepath)

        exts = set()
        for root, folders, files in os.walk(basepath):
            for file_ in files:
                _, ext = os.path.splitext(file_)
                if ext not in ('.py', '.pyc', '.pyo'):
                    exts.add('*' + ext)

        exts = list(exts)
        text = templ.SETUPFILE.format(**opts)

        # generate the file
        if not os.path.exists(outfile):
            f = open(outfile, 'w')
            f.write(text)
            f.close()

        # generate the manifest file
        manfile = os.path.join(outpath, 'MANIFEST.in')
        if not os.path.exists(manfile):
            f = open(manfile, 'w')
            f.write('include *.md *.txt *.ini *.cfg *.rst\n')
            f.write('recursive-include {0} {1}\n'.format(self.name(), ' '.join(exts)))
            f.close()

        # generate the egg
        if egg:
            cmd = 'cd {0} && $PYTHON setup.py bdist_egg'.format(outpath)
            cmd = os.path.expandvars(cmd)
            cmdexec(cmd)
957505
def write_outfile(method_name, file)
      schema = @load_schema.call(self)
      context = @load_context.call(self)
      result = schema.public_send(method_name, only: @only, except: @except, context: context)
      dir = File.dirname(file)
      FileUtils.mkdir_p(dir)
      File.write(file, result)
    end
38404
public function generateFiles()
    {
        foreach ($this->getFiles() as $stub => $file) {
            $path = $this->module->getModulePath($this->getName()) . $file;

            if (!$this->filesystem->isDirectory($dir = dirname($path))) {
                $this->filesystem->makeDirectory($dir, 0775, true);
            }

            $this->filesystem->put($path, $this->getStubContents($stub));
        }
    }
1184940
public void writeXsd(File outFile) {

    File folder = outFile.getParentFile();
    if (!folder.isDirectory()) {
      boolean success = folder.mkdirs();
      if (!success) {
        throw new IllegalStateException("Failed to create folder " + folder);
      }
    }
    try (FileOutputStream fos = new FileOutputStream(outFile)) {
      writeXsd(fos);
    } catch (Exception e) {
      throw new IllegalStateException("Failed to generate and write the XSD schema to " + outFile + "!", e);
    }
  }
723246
function createFileTree (filePaths)
{
  var path = require ('path')
    , root = {
    files:      [],
    subfolders: new Map
  };

  filePaths.forEach (function (filename)
  {
    var dir = path.dirname (filename)
      , folderPtr = root;
    if (dir)
      dir.split (path.sep).forEach (function (segment)
      {
        if (!folderPtr.subfolders.has (segment))
          folderPtr.subfolders.set (segment, {
            files:      [],
            subfolders: new Map
          });
        folderPtr = folderPtr.subfolders.get (segment);
      });
    folderPtr.files.push (filename);
  });
  return root;
}
269395
def make_file_system_tree(root_folder, _parent=None):
    
    root_node = Node(os.path.basename(root_folder), _parent)
    root_node.path = root_folder
    for item in os.listdir(root_folder):
        item_path = os.path.join(root_folder, item)
        if os.path.isfile(item_path):
            file_node = Node(os.path.basename(item), root_node)
            file_node.path = item_path
        elif os.path.isdir(item_path):
            #folder_path = os.path.join(root_folder, item)
            make_file_system_tree(item_path, _parent=root_node)
    return root_node
133835
public static FileWriter createFile(String name, String outDir) throws IOException
   {
      File path = new File(outDir);
      if (!path.exists())
      {
         if (!path.mkdirs())
            throw new IOException("outdir can't be created");
      }

      File file = new File(path.getAbsolutePath() + File.separatorChar + name);

      if (file.exists())
      {
         if (!file.delete())
            throw new IOException("there is exist file, please check");
      }

      return new FileWriter(file);
   }
197243
private function copyStubsDirectory()
    {
        $path = $this->option('path');

        // if controller stub already exist
        if ($this->files->exists($path . DIRECTORY_SEPARATOR . 'controller.stub') && $this->option('force') === false) {
            $this->error("Stubs already exists! Run 'generate:publish-stubs --force' to override the stubs.");
            die;
        }

        File::copyDirectory(__DIR__ . '/../../resources/stubs', $path);
    }
480839
def build_output_directory(self, path):
        '''
        
        '''
        # If we have not already created an output directory for this target
        # file, create one now
        if not has_key(self.extraction_directories, path):
            basedir = os.path.dirname(path)
            basename = os.path.basename(path)

            if basedir != self.directory:
                # During recursive extraction, extracted files will be in subdirectories
                # of the CWD. This allows us to figure out the subdirectory by simply
                # splitting the target file's base directory on our known CWD.
                #
                # However, the very *first* file being scanned is not necessarily in the
                # CWD, so this will raise an IndexError. This is easy to handle though,
                # since the very first file being scanned needs to have its contents
                # extracted to ${CWD}/_basename.extracted, so we just set the subdir
                # variable to a blank string when an IndexError is encountered.
                try:
                    subdir = basedir.split(self.directory)[1][1:]
                except IndexError as e:
                    subdir = ""
            else:
                subdir = ""

            if self.output_directory_override:
                output_directory = os.path.join(self.directory, subdir, self.output_directory_override)
            else:
                outdir = os.path.join(self.directory, subdir, '_' + basename)
                output_directory = unique_file_name(outdir, extension='extracted')

            if not os.path.exists(output_directory):
                os.mkdir(output_directory)

            self.extraction_directories[path] = output_directory
            self.output[path].directory = os.path.realpath(output_directory) + os.path.sep
        # Else, just use the already created directory
        else:
            output_directory = self.extraction_directories[path]

        return output_directory
281358
static public function buildAbsolutePath($relative_path, $basepath) {
        if (strpos($relative_path, static::PATH_SEGMENT_SEPARATOR) === 0) {
            return static::normalizePath($relative_path);
        }
        $basedir = static::dirname($basepath);
        if ($basedir == '.' || $basedir == static::PATH_SEGMENT_SEPARATOR || $basedir == '\\' || $basedir == DIRECTORY_SEPARATOR) $basedir = '';
        return static::normalizePath($basedir . self::PATH_SEGMENT_SEPARATOR . $relative_path);
    }
1287817
public static ArchivePath create(String basePath, String context) {
        return createInstance(new Class<?>[] { String.class, String.class }, new Object[] { basePath, context });
    }
1032835
static String makeRelative(Path root, Path absPath) {
    if (!absPath.isAbsolute()) {
      throw new IllegalArgumentException("!absPath.isAbsolute(), absPath="
          + absPath);
    }
    String p = absPath.toUri().getPath();

    StringTokenizer pathTokens = new StringTokenizer(p, "/");
    for(StringTokenizer rootTokens = new StringTokenizer(
        root.toUri().getPath(), "/"); rootTokens.hasMoreTokens(); ) {
      if (!rootTokens.nextToken().equals(pathTokens.nextToken())) {
        return null;
      }
    }
    StringBuilder sb = new StringBuilder();
    for(; pathTokens.hasMoreTokens(); ) {
      sb.append(pathTokens.nextToken());
      if (pathTokens.hasMoreTokens()) { sb.append(Path.SEPARATOR); }
    }
    return sb.length() == 0? ".": sb.toString();
  }
1268876
private void createDirAndFile(Path path) throws IOException {
			// create dir and file first if dir/file not exist
			File file = new File(path.toAbsolutePath().toString());
			File dir = file.getParentFile();
			if (dir != null && !dir.exists()) {
				dir.mkdirs();
			}
			if (!file.exists()) {
				file.createNewFile();
			}
	}