Flatten the path to the desired depth

@param {File} file - vinyl file
@param {Object} options
@return {String}
329193
function flattenPath(file, opts) {
  var fileName = path.basename(file.path);
  var dirs;

  if (!opts.includeParents && !opts.subPath) {
    return fileName;
  }

  dirs = path.dirname(file.relative).split(path.sep);
  if (opts.includeParents) {
    dirs = includeParents(dirs, opts.includeParents);
  }
  if (opts.subPath) {
    dirs = subPath(dirs, opts.subPath);
  }

  dirs.push(fileName);
  return path.join.apply(path, dirs);
}
890753
function resolvePathFor(options, src) {
  if (Array.isArray(src)) {
    src.forEach(dir => resolvePathFor(options, dir));
  } else {
    const relativePath = get(options, src);
    if (Array.isArray(relativePath)) {
      set(options, src, relativePath.map(n => getAbsPath(n)));
    } else {
      const _absPath = getAbsPath(relativePath);
      relativePath !== _absPath && set(options, src, _absPath);
    }
  }
}
173429
function File(file, options) {
  Item.call(this, file, options);
  this.initFile(file);
  return file;
}
1184747
function (file) {

        var that = this;
        var error = false;
        var walk;

        if (file) {


            var fileList = typeof file === 'string' ? [file] : file;

            fileList = fileList.map(function (file) {
                return path.resolve(that.base, file);
            });

            walk = function (list) {

                list.forEach(function (file) {

                    if (error) {
                        return;
                    }

                    error = !that._compile(file);

                });
            };


            walk(fileList);

            if (!error && this.options.combo) {
                this._combo();
            }

        } else {


            walk = function (dir) {

                if (dir === that.output) {
                    return;
                }

                var dirList = fs.readdirSync(dir);

                dirList.forEach(function (item) {

                    if (error) {
                        return;
                    }

                    if (fs.statSync(path.join(dir, item)).isDirectory()) {
                        walk(path.join(dir, item));
                    } else if (that.filterBasename(item) && that.filterExtname(item)) {
                        error = !that._compile(path.join(dir, item));
                    }

                });
            };


            walk(this.base);

            if (!error && this.options.combo) {
                this._combo();
            }
        }

    }
659570
function flatten(obj,callback) {
    let arr = [];
    let iDepth, oDepth = 0;
    let state = {identityDetection:true};
    recurse(obj,state,function(obj,key,state){
        let entry = {};
        entry.name = key;
        entry.value = obj[key];
        entry.path = state.path;
        entry.parent = obj;
        entry.key = key;
        if (callback) entry = callback(entry);
        if (entry) {
            if (state.depth > iDepth) {
                oDepth++;
            }
            else if (state.depth < iDepth) {
                oDepth--;
            }
            entry.depth = oDepth;
            iDepth = state.depth;
            arr.push(entry);
        }
    });
    return arr;
}
1307073
function(path, options) {

        var errors = hintFiles([path],
                               {options: options.jshintOptions,
                                withDefaults: options.withDefaults,
                                globals: options.globals},
                               false);
        var flattened_errors = [].concat.apply([], errors);
        var formatted_errors = flattened_errors.map(function(error) {
            return '' + path + ': ' + error.line + ":" + error.character + " " + error.reason;
        });

        return formatted_errors.join('\n');
    }
1319305
function(file, opts) {
	if (util.isObject(file) || util.isArray(file)) {
		return file;
	}

	var options = util.extend({
		asText: false, // true, false, 'pretty'
		javascript: false, // true, false
		scope: '', // directory to look for initial file
		variables: {
			// contains a key->value object with variables to @extends
		}
	}, opts);

	file = util.template(file, options.variables);

	/*****************************************************************************
	*  Initialize
	*****************************************************************************/

	var file_path;

	// If the file path is absolute use it
	// If not then prepend the current scope of the previous file.
	if (path.resolve(file) === path.normalize(file)) {
		file_path = path.normalize(file);
	}
	else {
		file_path = path.normalize(
			options.scope ? options.scope + '/' + file : file
		);
	}
	var class_json = parseFile(file_path, options);

	// Stores JSON objects of files that have to be merged together:
	// ["a", "b"]
	var file_list = util.isArray(class_json[indicators.EXTENDS]) ?
		class_json[indicators.EXTENDS] :
		class_json[indicators.EXTENDS] != null ?
			[ class_json[indicators.EXTENDS] ] :
			[];

	// Delete @extends from base_json to avoid infinitive recursion
	delete class_json[indicators.EXTENDS];

	// Push class_json to the path list:
	file_list.push(class_json);
	/*****************************************************************************
	*  Merge file by file
	*****************************************************************************/

	// default config for each file required:
	// set asText = false so we get an object returned
	// set scope = file's directory so there can be relative references
	var json_config = util.defaults({
		asText: false,
		scope: path.dirname(file_path),

		// _as is a hack so that we know its we are calling the function recursive
		_as: ANTI_SANITIZER
	}, options);

	// super_json is our output, start by containing first file in array
	var super_json = fromFile(file_list.shift(), json_config);

	// TODO: Figure out when to sanitize super_json hopefully we don't have to
	//   santize all returns. I'm not sure about this, and I'm not sure if we
	//   can even sanitize super_json when we return it.
	//   Is super_json used by anyone recursively?

	while (file_list.length) {
		var json = fromFile(file_list.shift(), json_config);

		merge(super_json, json);
	}

	// If this file is called from the outside eg json_merger.from...
	//   File('file_which_doesnt_extends_another_file.json')
	//   we need to sanitize the file and remove all indicators
	if (options._as != ANTI_SANITIZER) {
		super_json = util.sanitizeValue(super_json);
	}

	/*****************************************************************************
	*  Return super_json
	*****************************************************************************/
	if (options.asText) {
		return stringify(super_json, options);
	}
	else {
		return super_json;
	}
}
1308394
function relativeTOC(file, parent) {
        _.each(parent.children, function(child) {
          if(child.relative) {
            var href = "";
            if(config.format != "pdf") {
              var relativeFolder = path.relative(path.dirname(file.relative), path.dirname(child.relative));
              href = path.join(relativeFolder, path.basename(child.relative))
            }
            if(child.id) {
              href += "#" + child.id;
            }
            child.href = href;
          }
          if(child.children) {
            child = relativeTOC(file, child);
          }
        });
        return parent;
      }
315465
function resolve(file) {
  // not too sure about windows, but put the \\
  // just in case
  if(!/^(\\\\|\/)/.test(file)) {
    return path.normalize(path.join(process.cwd(), file));
  }
  return file;
}
147255
def relpath_to(*pathsegs)
      ArgumentError.arity_at_least!(pathsegs, 1)
      pathsegs = pathsegs.flatten.map { |ps| expand_pathseg(ps) }.flatten
      self.new(File.join(*pathsegs)).cleanpath(true)
    end
407761
function startline(opt) {

  var options = opt || Object.create(null);

  // file
  var file;
  if (Boolean(options.file)) {
    file = require('path').resolve(String(options.file));
    if (!fs.existsSync(file)) {
      throw new Error('file does not exist');
    }
    if (!fs.statSync(file).isFile()) {
      throw new Error('path is not a file');
    }
  } else {
    throw new Error('"file" is required');
  }

  // clean
  var my = {
    file: file,
    encoding: options.encoding,
    flag: String(options.flag || 'r'),
    mode: Number(options.mode) || 444,
    autoClose: options.autoClose === false ? false : true,
    start: Number(options.start) || 0,
    end: Number(options.end),
    rc4: options.rc4,
    autokey: options.autokey,
    lodash: Boolean(options.autokey),
  };

  return new Startline(my);
}
1197037
function getDirFromPublicPath(file) {
	return path.posix.dirname(
		path.posix.normalize(
			path.posix.sep
			+ file.path().replace(
				new RegExp(
					'^' + escapeStringRegExp(path.resolve(Config.publicPath))
				),
				''
			).split(path.sep).join(path.posix.sep)
		)
	);
}
274166
public static Optional<String> relativize(Path dir, Path file) {
    Path baseDir = dir.normalize();
    Path path = file.normalize();
    if (!path.startsWith(baseDir)) {
      return Optional.empty();
    }
    try {
      Path relativized = baseDir.relativize(path);
      return Optional.of(FilenameUtils.separatorsToUnix(relativized.toString()));
    } catch (IllegalArgumentException e) {
      return Optional.empty();
    }
  }
389251
function buildResolverOptions(options, base) {
  var pathFilter = options.pathFilter;

  options.basedir = base;
  options.pathFilter = function(info, resvPath, relativePath) {
    if (relativePath[0] !== '.') {
      relativePath = './' + relativePath;
    }
    var mappedPath;
    if (pathFilter) {
      mappedPath = pathFilter.apply(this, [info, resvPath, path.normalize(relativePath)]);
    }
    if (mappedPath) {
      return mappedPath;
    }
    return;
  };
  return options;
}
1361605
def clean_path_to(file, options = {})
      # Allow individual calls to this method to specify additional custom load paths to consider
      if options[:load_paths]
        [options[:load_paths]].each do |root|
          if File.exist?("#{root}/#{file}")
            return Pathname.new("#{root}/#{file}")
          end
        end
      end
      if File.exist?(file)
        if Pathname.new(file).absolute?
          Pathname.new(file)
        else
          Pathname.new("#{Pathname.pwd}/#{file}")
        end
      # Is it a relative reference within a list file?
      elsif @last_opened_list_dir && File.exist?("#{@last_opened_list_dir}/#{file}")
        Pathname.new("#{@last_opened_list_dir}/#{file}")
      # Is it a relative reference to the current base directory?
      elsif File.exist?("#{base_directory}/#{file}")
        Pathname.new("#{base_directory}/#{file}")
      # Is it a path relative to Origen.root?
      elsif File.exist?("#{Origen.root}/#{file}")
        Pathname.new("#{Origen.root}/#{file}")
      # Is it a path relative to the current directory?
      elsif current_directory && File.exist?("#{current_directory}/#{file}")
        Pathname.new("#{current_directory}/#{file}")
      # Is it a path relative to the current plugin's Origen.root?
      elsif Origen.app.plugins.current && File.exist?("#{Origen.app.plugins.current.root}/#{file}")
        Pathname.new("#{Origen.app.plugins.current.root}/#{file}")
      elsif options[:default_dir]
        m = all_matches(file, options)
        if m
          Pathname.new(m)
        else
          if options[:allow_missing]
            return nil
          else
            fail "Can't find: #{file}"
          end
        end
      else
        if options[:allow_missing]
          return nil
        else
          fail "Can't find: #{file}"
        end
      end
    end
960114
function (file) {
        if (!this.ignore(file)) {
            file = this.map(file);
            file = utils.normalize(file);
            return file;
        }
    }
79181
public static String flatten(String uri)
	{
		URI normalized = URI.create( raw( uri ) ).normalize();
		String path = normalized.getPath();
		path = stripLeadingSlash( path );
		path = path.replaceAll( "/", "-" );
		return path;
	}