depth=2, fixes path to targetDir
320579
function buildRooms(baseRoom, dir, depth, attachments) {
        depth++;

        // group attachments
        attachments = _.chain(attachments)
            .clone()
            .concat(baseRoom.getMedia(false).map(file => path.join('media', path.relative(commonFolder, file))))
            .uniq()
            .value();

        baseRoom.items.forEach((room, i) => {
            let itemPath = path.join(dir, i.toString());
            fs.ensureDirSync(itemPath);

            if (!room.hasFiles) {
                buildRooms(room, itemPath, depth, attachments);
            } else {
                const roomsFiles = room.parsedFiles.map(file => {
                    file.destination = path.join(itemPath, 'files', file.parse.base);
                    file.content = fs.readFileSync(file.file, 'utf8');
                    file.mode = file.parse.ext.replace('.', '');
                    fs.copySync(file.file, file.destination);
                    return file;
                });

                // room attachments
                attachments = _.chain(attachments)
                    .clone()
                    .concat(room.getMedia(false).map(file => path.join('media', path.relative(commonFolder, file))))
                    .uniq()
                    .value();

                const css_paths = _.chain(attachments)
                    .concat(roomsFiles.map(file => path.relative(targetDir, file.destination)))
                    .filter(file => _.endsWith(file, '.css'))
                    .map(file => normalizePath(file, false))
                    .value();

                const js_paths = _.chain(attachments)
                    .concat(roomsFiles.map(file => path.relative(targetDir, file.destination)))
                    .filter(file => _.endsWith(file, '.js'))
                    .map(file => normalizePath(file, false))
                    .value();

                // iframe.html
                fs.writeFileSync(
                    path.join(itemPath, 'iframe.html'),
                    handlebars.compile(iframe)({
                        depth,
                        css_paths,
                        js_paths,
                        html: roomsFiles[0],
                    })
                );

                // index.html
                fs.writeFileSync(
                    path.join(itemPath, 'index.html'),
                    handlebars.compile(index)({
                        depth,
                        roomsFiles,
                        settings,
                        root,
                        room,
                        css_paths,
                        js_paths,
                        hasCSS: css_paths.length > 0,
                        hasJS: js_paths.length > 0,
                    })
                );
            }
        });
    }
360200
def do_mkdir(self, path):
        """"""
        path = path[0]

        self.n.makeDirectory(self.current_path + path)
        self.dirs = self.dir_complete()
1204756
def _touch_dir(self, path):
        
        try:
            os.makedirs(path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise
775302
function addToPath(directory) {
  var srcs = process.env.PATH.split(delimiter);
  if (srcs.indexOf(directory) === -1) {
    srcs.unshift(directory);
    process.env.PATH = srcs.join(delimiter);
    debug('added `%s` to $PATH and its now `%s`',
      directory, process.env.PATH);
  }
}
747579
def tmp_chdir(new_path):
    """"""
    prev_cwd = os.getcwd()
    os.chdir(new_path)
    try:
        yield
    finally:
        os.chdir(prev_cwd)
672066
def _create_target_dir_if_needed(self, target, depth_limit=20):
        """"""

        if depth_limit <= 0:
            raise FtpCreateDirsException('Depth limit exceeded')
        if not target:
            return
        target_dir = os.path.dirname(target)
        parent_dir, dir_name = os.path.split(target_dir)

        parent_dir_ls = []
        try:
            parent_dir_ls = self.ftp.nlst(parent_dir)
        except:
            # Possibly a microsoft server
            # They throw exceptions when we try to ls non-existing folders
            pass

        parent_dir_files = [os.path.basename(d) for d in parent_dir_ls]
        if dir_name not in parent_dir_files:
            if parent_dir and target_dir != '/':
                self._create_target_dir_if_needed(target_dir, depth_limit=depth_limit - 1)

            self.logger.info('Will create dir: %s' % target)
            self.ftp.mkd(target_dir)
1104996
function determineTargetDir(source, target) {
	return stat(source).
		then(results => results.isDirectory() ? target : path.dirname(target));
}
137530
def paths_by_depth(paths):
    
    return sorted(
            paths,
            key=lambda path: path.count(os.path.sep),
            reverse=True
    )
756142
def fix_path(path):
    
    if '\\' in path:
        path = path.replace('\\', '/')

    path = os.path.normpath(path)

    return path
1342779
def cd(self, *subpaths):
        
        target = os.path.join(*subpaths)
        os.chdir(target)
965826
def _depth_limited_walk(top, max_depth=None):
    '''
    
    '''
    for root, dirs, files in salt.utils.path.os_walk(top):
        if max_depth is not None:
            rel_depth = root.count(os.path.sep) - top.count(os.path.sep)
            if rel_depth >= max_depth:
                del dirs[:]
        yield (six.text_type(root), list(dirs), list(files))
1291682
function normalizePaths(opts) {
  for (var srcKey in opts.src) {
    if (!path.isAbsolute(opts.src[srcKey].glob)) {
      opts.src[srcKey].glob = path.resolve(opts.src[srcKey].glob);
    }
    if (!path.isAbsolute(opts.src[srcKey].basedir)) {
      opts.src[srcKey].basedir = path.resolve(opts.src[srcKey].basedir);
    }
  }
}
1253393
def chdir(self, dir, change_os_dir=0):
        
        curr=self._cwd
        try:
            if dir is not None:
                self._cwd = dir
                if change_os_dir:
                    os.chdir(dir.get_abspath())
        except OSError:
            self._cwd = curr
            raise
665199
def TargetDirectory(ID, season, relative=False, **kwargs):
    '''
    

    '''

    if season is None:
        return None
    if relative:
        path = ''
    else:
        path = EVEREST_DAT
    return os.path.join(path, 'k2', 'c%02d' % season,
                        ('%09d' % ID)[:4] + '00000',
                        ('%09d' % ID)[4:])
444415
def fix_path(p):
    
    venv_lib = get_python_lib()

    if p.startswith(venv_lib):
        subdir = p[len(venv_lib) + 1:]

        for sitedir in getsyssitepackages():
            fixed_path = join(sitedir, subdir)
            if isdir(fixed_path):
                return fixed_path

    return p
1310490
function ensureRelative(outputDir, p) {
    if (path.isAbsolute(p)) {
        return path.relative(outputDir, p);
    } else {
        return p;
    }
}
242455
function shiftDeepValue(target, path) {
    var deepRef = getDeepRef(target, path);
    if (!isArray(deepRef))
        return;
    return deepRef.shift();
}