convert java.io.files into relative paths under the root container.
163756
private Set<String> convertAbsToRelative(Collection<File> files) {
        Set<String> result = new HashSet<String>();
        for (File f : files) {
            String fAbsPath = PathUtils.fixPathString(f); //assumption here that f is a dir, and path will end in File.seperator
            if (fAbsPath.startsWith(rootAbsolutePath)) {
                String absPath = fAbsPath; // canonicalPath(f);
                absPath = absPath.substring(rootAbsolutePath.length());
                if ("\\".equals(File.separator)) {
                    absPath = absPath.replace('\\', '/');
                }
                //handle / case. (path will have been the same, so the substring created emptystring)
                if (absPath.length() == 0) {
                    absPath = "/";
                }
                result.add(absPath);
            } else
                throw new IllegalStateException(fAbsPath + " " + rootAbsolutePath);
        }
        return result;
    }
663155
def _get_files_to_lint(self, external_directories):
        """"""
        all_f = []

        for external_dir in external_directories:
            all_f.extend(_all_files_matching_ext(external_dir, "py"))

        packages = self.distribution.packages or list()
        for package in packages:
            all_f.extend(_all_files_matching_ext(package, "py"))

        py_modules = self.distribution.py_modules or list()
        for filename in py_modules:
            all_f.append(os.path.realpath(filename + ".py"))

        all_f.append(os.path.join(os.getcwd(), "setup.py"))

        # Remove duplicates which may exist due to symlinks or repeated
        # packages found by /setup.py
        all_f = list(set([os.path.realpath(f) for f in all_f]))

        exclusions = [
            "*.egg/*",
            "*.eggs/*"
        ] + self.exclusions
        return sorted([f for f in all_f if not _is_excluded(f, exclusions)])
822911
public String relativePath(File base, File nested) throws IOException {
        String basePath = base.getCanonicalPath();
        String nestedPath = nested.getCanonicalPath();
        if (nestedPath.equals(basePath)) {
            return "";
        } else if (nestedPath.startsWith(basePath)) {
            return nestedPath.substring(basePath.length() + 1);
        } else {
            return nestedPath;
        }
    }
788722
def relative_path(path):
    
    return os.path.join(os.path.dirname(__file__), path)
321451
def filetree(collector, *paths):
    '''
    
    '''
    _paths = []
    # Unglob
    for path in paths:
        _paths += glob.glob(path)
    for path in set(_paths):
        if not path:
            out.error('Path not defined', ident=2)
        elif not os.path.exists(path):
            out.warning('Path {} does not exists'.format(path))
        else:
            # The filehandler needs to be explicitly passed here, so PyLint needs to accept that.
            # pylint: disable=W8470
            if os.path.isfile(path):
                filename = os.path.basename(path)
                try:
                    file_ref = salt.utils.files.fopen(path)  # pylint: disable=W
                    out.put('Add {}'.format(filename), indent=2)
                    collector.add(filename)
                    collector.link(title=path, path=file_ref)
                except Exception as err:
                    out.error(err, ident=4)
            # pylint: enable=W8470
            else:
                try:
                    for fname in os.listdir(path):
                        fname = os.path.join(path, fname)
                        filetree(collector, [fname])
                except Exception as err:
                    out.error(err, ident=4)
1307054
def pkgPath(root, path, rpath="/"):
    
    global data_files
    if not os.path.exists(path):
        return
    files = []
    for spath in os.listdir(path):
        # Ignore test directories
        if spath == 'test':
            continue
        subpath = os.path.join(path, spath)
        spath = os.path.join(rpath, spath)
        if os.path.isfile(subpath):
            files.append(subpath)
        if os.path.isdir(subpath):
            pkgPath(root, subpath, spath)
    data_files.append((root + rpath, files))
481473
def relative_root_dir(self):
        """"""
        return Path(self.bundle.name) / str(self.created_at.date())
359294
function resolveImportPaths(filePath, importPaths){
  var dir = path.dirname(filePath);
  return importPaths.map(function(relativePath){
    if(!path.extname(relativePath)){
      relativePath += '.less';
    }
    return path.resolve(dir, relativePath);
  });
}
41772
def make_relative_to_root(path):
  """"""
  return os.path.normpath(path.format(pex_root=ENV.PEX_ROOT))
1033742
def package_files(directory):
    """"""
    paths = []
    for (path, _, file_names) in walk(directory):
        for filename in file_names:
            paths.append(join('..', path, filename))
    return paths
941170
def convertPath(srcpath, dstdir):
    """"""
    bits = srcpath.split("/")
    bits.pop(0)
    # Strip out leading 'unsigned' from paths like unsigned/update/win32/...
    if bits[0] == 'unsigned':
        bits.pop(0)
    return os.path.join(dstdir, *bits)
284666
private static Collection<? extends URL> doFindPathMatchingFileResources(final URL rootDirResource, final String subPattern) {

        File rootFile = null;
        final Set<URL> rets = new LinkedHashSet<URL>();

        try {
            rootFile = new File(rootDirResource.toURI());
        } catch (final URISyntaxException e) {
            LOGGER.log(Level.ERROR, "cat not resolve the rootFile", e);
            throw new RuntimeException("cat not resolve the rootFile", e);
        }
        String fullPattern = StringUtils.replace(rootFile.getAbsolutePath(), File.separator, "/");

        if (!subPattern.startsWith("/")) {
            fullPattern += "/";
        }
        final String filePattern = fullPattern + StringUtils.replace(subPattern, File.separator, "/");

        @SuppressWarnings("unchecked") final Collection<File> files = FileUtils.listFiles(rootFile, new IOFileFilter() {
            @Override
            public boolean accept(final File dir, final String name) {
                return true;
            }

            @Override
            public boolean accept(final File file) {

                if (file.isDirectory()) {
                    return false;
                }
                if (AntPathMatcher.match(filePattern, StringUtils.replace(file.getAbsolutePath(), File.separator, "/"))) {
                    return true;
                }
                return false;
            }
        }, TrueFileFilter.INSTANCE);

        try {
            for (File file : files) {
                rets.add(file.toURI().toURL());
            }
        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, "convert file to URL error", e);
            throw new RuntimeException("convert file to URL error", e);
        }

        return rets;
    }
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
746932
def make_relative(base, obj):
    """"""
    uri = obj.get("location", obj.get("path"))
    if ":" in uri.split("/")[0] and not uri.startswith("file://"):
        pass
    else:
        if uri.startswith("file://"):
            uri = uri_file_path(uri)
            obj["location"] = os.path.relpath(uri, base)
548654
def source_files(self):
        """"""
        if 'srcs' in self.params and self.params['srcs'] is not None:
            return util.flatten(self.params['srcs'])
662803
public synchronized com.sun.tools.javac.util.List<String> getFiles(RelativeDirectory path) {
        try {
            checkIndex();

            DirectoryEntry de = directories.get(path);
            com.sun.tools.javac.util.List<String> ret = de == null ? null : de.getFiles();

            if (ret == null) {
                return com.sun.tools.javac.util.List.<String>nil();
            }
            return ret;
        }
        catch (IOException e) {
            return com.sun.tools.javac.util.List.<String>nil();
        }
    }
943335
private List<String> getPaths(String[] files) {
        final List<String> antStylePaths = new ArrayList<>();
        for (String file : files) {
            final String antPath = ensureCanonicalPath(file);
            antStylePaths.add(antPath);
        }
        return antStylePaths;
    }