Generate folder to files temporary of themes

This function replace true folder (that has all themes)
by one folder public, when accessed by request HTTP.
11585
public function buildPublicTmp ( $path ) {
        
        //repository of all themes        
        $repository  = $this->themeRepository();
        $repository  = Filter::realPath($repository);
        
        //repository to access files of themes (symbolically)
        $repository_tmp = $this->getFolderTmpTheme(); 
       
        $pos = strpos( $path, $repository );
        
        if ( $pos === 0)
            return $repository_tmp . substr($path, strlen($repository));

        return $path;
        
    }
380
function generatePath(path = "/", params = {}) {
  return path === "/" ? path : compilePath(path)(params, { pretty: true });
}
608868
def install_theme(path_to_theme):
    
    pref_init()
    # cp the file
    filename = basename(path_to_theme)
    dest = join(THEMES_DIR, filename)
    copy(path_to_theme, dest)
    # unzip
    zf = zipfile.ZipFile(dest)
    # should make sure zipfile contains only themename folder which doesn't conflict
    # with existing themename. Or some kind of sanity check
    zf.extractall(THEMES_DIR)  # plus this is a potential security flaw pre 2.7.4
    # remove the copied zipfile
    unlink(dest)
197034
def _tmpfile(self, cache_key, use):
    """"""
    with temporary_file(suffix=cache_key.id + use, root_dir=self._cache_root,
                        permissions=self._permissions) as tmpfile:
      yield tmpfile
957671
def generate_pages_by_file():
    """"""
    from veripress import app
    from veripress.model import storage
    from veripress.model.parsers import get_standard_format_name
    from veripress.helpers import traverse_directory

    deploy_dir = get_deploy_dir()

    def copy_file(src, dst):
        makedirs(os.path.dirname(dst), mode=0o755, exist_ok=True)
        shutil.copyfile(src, dst)

    with app.app_context(), app.test_client() as client:
        root_path = os.path.join(app.instance_path, 'pages')
        for path in traverse_directory(root_path):
            # e.g. 'a/b/c/index.md'
            rel_path = os.path.relpath(path, root_path)
            # e.g. ('a/b/c/index', '.md')
            filename, ext = os.path.splitext(rel_path)
            if get_standard_format_name(ext[1:]) is not None:
                # is source of custom page
                rel_url = filename.replace(os.path.sep, '/') + '.html'
                page = storage.get_page(rel_url, include_draft=False)
                if page is not None:
                    # it's not a draft, so generate the html page
                    makedirs(os.path.join(deploy_dir,
                                          os.path.dirname(rel_path)),
                             mode=0o755, exist_ok=True)
                    with open(os.path.join(deploy_dir, filename + '.html'),
                              'wb') as f:
                        f.write(client.get('/' + rel_url).data)
                if app.config['PAGE_SOURCE_ACCESSIBLE']:
                    copy_file(path, os.path.join(deploy_dir, rel_path))
            else:
                # is other direct files
                copy_file(path, os.path.join(deploy_dir, rel_path))
765922
function createOutputDirs(done) {
			o.stylesheets.forEach(function(stylesheet) {
				mkdirp.sync(option(o.destCssPaths, stylesheet));
			});
			mkdirp.sync(o.dest);
			done();
		}
573682
protected function createFolderIfMissing()
    {
        if (!file_exists($this->webPath . '/' . $this->imageFolder)) {
            mkdir($this->webPath . '/' . $this->imageFolder, 0755);
        }
    }
336017
def generate
      sitemaps.group_by(&:folder).each do |folder, sitemaps|
        index_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{DynamicSitemaps.index_file_name}"

        if !DynamicSitemaps.always_generate_index && sitemaps.count == 1 && sitemaps.first.files.count == 1
          file_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{sitemaps.first.files.first}"
          FileUtils.copy file_path, index_path
          File.delete file_path
        else
          File.open(index_path, "w") do |file|
            write_beginning(file)
            write_sitemaps(file, sitemaps)
            write_end(file)
          end
        end
      end
    end
56568
public static File createTempDirectory(String prefix, Path dir) throws IOException {
        if (prefix == null) {
            prefix = "";
        }
        final File file = generatePath(prefix, dir).toFile();
        if (!file.mkdirs()) {
            throw new IOException("Can't create dir " + file.getAbsolutePath());
        }
        return file;
    }
1301998
def temp_directory(*args, **kwargs):
    

    path = tempfile.mkdtemp(*args, **kwargs)
    try:
        yield path
    finally:
        shutil.rmtree(path)
159475
def _prepare_temp_dir(self):
    """"""
    shell_call(['rm', '-rf', os.path.join(self._temp_dir, '*')])
    # NOTE: we do not create self._extracted_submission_dir
    # this is intentional because self._tmp_extracted_dir or it's subdir
    # will be renames into self._extracted_submission_dir
    os.mkdir(self._tmp_extracted_dir)
    os.mkdir(self._sample_input_dir)
    os.mkdir(self._sample_output_dir)
    # make output dir world writable
    shell_call(['chmod', 'a+rwX', '-R', self._sample_output_dir])
1143350
def createHiddenFolder(self) -> 'File':
        

        if not self._autoDelete:
            raise Exception("Hidden folders can only be created within"
                            " an autoDelete directory")
        return tempfile.mkdtemp(dir=self._path, prefix=".")
131663
def make_offline():
    
    dir_path = Path(os.getcwd()).absolute()

    css_path = dir_path / "site" / "assets" / "stylesheets"
    material_css = css_path / "material-style.css"
    if not material_css.exists():
        file_path = Path(__file__).resolve().parent
        copyfile(file_path / "material-style.css", material_css)
        copyfile(file_path / "material-icons.woff2", css_path / "material-icons.woff2")

    indexes = []
    for root, _, filenames in os.walk(dir_path / "site"):
        for filename in fnmatch.filter(filenames, "index.html"):
            indexes.append(os.path.join(root, filename))
    for index_file in indexes:
        update_index_to_offline(index_file)
286116
function replaceBaseHref (folder) {
    // handle index.html
    const filePath = path.join(__dirname, '/code.material.angularjs.org/', folder, '/index.html');
    const file = fs.readFileSync(filePath);
    const contents = file.toString().replace(/base href="\//g, 'base href="/' + folder + '/');
    fs.writeFileSync(filePath, contents);
  }
742342
function generate (projectPatch, source, done) {
  shell.mkdir('-p', projectPatch)
  shell.cp('-Rf', source, projectPatch)
  done()
}
164258
function generateUtilityFiles(next) {
    fs.copy(path.join(getConfig('template.folder'), 'index.js'), path.join(getConfig('output.folder'), 'index.js'), function (err) {
        if (err) { next(err); return; }
        if (getConfig('output.log')) { logger.info('(Created) Index file: ' + path.resolve(path.join(getConfig('output.folder'), 'index.js'))); }
        fs.copy(path.join(getConfig('template.folder'), '..', 'utils.js'), path.join(getConfig('output.folder'), 'utils.js'), function (err) {
            if (err) { next(err); return; }
            next(null);
        });
    });
    try {
        overriddenAliases = require(path.join(process.cwd(), getConfig('output.folder'), 'alias.json'));
    } catch (ignore) {}
}
221522
function openFile(themeId, folderName, fileName) {
        if (themeId && folderName && fileName) {
            //if image then display it
            if (folderName === "images") {
                showImage(themeId, folderName, fileName);
                return;
            }

            var options = {
                url:getURL("show") + "/" + themeId + "/" + folderName + "/" + fileName,
                success:function (response) {
                    if (response.status === "error") {
                        util.showErrorFlash(response.message);
                    }
                    else {
                        // if js, css or jade file then show in editor
                        var mode = "scss";
                        if (fileName.indexOf(".js") > -1) {
                            mode = "javascript";
                        }
                        else if (fileName.indexOf(".css") > -1) {
                            mode = "css";
                        }

                        initAceEditor(themeId, folderName, fileName, response, mode);
                    }
                }
            };
            Rocket.ajax(options);
        }
    }