1. find the absolute root directory
2. check for wildcards

@param incPath
@param cwd
@return
172936
@SuppressWarnings("IndexOfReplaceableByContains")
    public static List<File> resolvePath(File incPath, File cwd) {
        if(cwd == null)
            cwd = new File(Config.getHomeDir());

        //if incPath start with eg: ./, remove it
        if(incPath.toString().startsWith(CURRENT_WITH_SEPARATOR)) {
            incPath = new File(incPath.toString().substring(CURRENT_WITH_SEPARATOR.length()));
        }

        if(incPath.toString().startsWith(TILDE_WITH_SEPARATOR)) {
            if(Config.getHomeDir().endsWith(Config.getPathSeparator()))
                incPath = new File(Config.getHomeDir()+incPath.toString().substring(2));
            else
                incPath = new File(Config.getHomeDir()+incPath.toString().substring(1));
        }

        if(incPath.toString().indexOf(TILDE) == 0) {
            if(incPath.toString().length() > 1) {
                // directories which name starts with tilde
                incPath = new File(cwd.toString() + Config.getPathSeparator() + incPath.toString());
            } else {
                incPath = new File(Config.getHomeDir());
            }
        }

        //  foo1/./foo2 is changed to foo1/foo2
        if(incPath.toString().indexOf(SEPARATOR_CURRENT_SEPARATOR) > -1) {
            int index = incPath.toString().indexOf(SEPARATOR_CURRENT_SEPARATOR);
            if(index == 0) {
                incPath = new File(incPath.toString().substring(SEPARATOR_CURRENT_SEPARATOR.length()-1));
            }
            else {
                incPath = new File(incPath.toString().substring(0, index) +
                        incPath.toString().substring(index+2, incPath.toString().length()));
            }
        }

        //parentPath do not start with / or by a windows driver letter and cwd is not / either
        if( incPath.toString().indexOf(ROOT) != 0 && incPath.toString().indexOf(DRIVER_SEPARATOR) == -1 && !cwd.toString().equals(ROOT)) {
            if(cwd.toString().endsWith(Config.getPathSeparator()))
                incPath = new File(cwd.toString() + incPath.toString());
            else
                incPath = new File(cwd.toString() + Config.getPathSeparator() + incPath.toString());
        }

        if(incPath.toString().indexOf(PARENT_WITH_SEPARATOR) > -1) {
            String tmp = incPath.toString();
            while(tmp.indexOf(PARENT_WITH_SEPARATOR) > -1) {
                int index = tmp.indexOf(PARENT_WITH_SEPARATOR);
                if(index == 0) {
                    tmp = tmp.substring(PARENT_WITH_SEPARATOR.length());
                }
                else {
                    File tmpFile = new File(tmp.substring(0, index));
                    tmpFile = tmpFile.getParentFile();
                    if(tmpFile == null)
                        tmpFile = new File(Config.getPathSeparator());
                    tmpFile = new File(tmpFile.toString() + tmp.substring(index+ PARENT_WITH_SEPARATOR.length()-1));
                    //tmp = tmp.substring(0, index) + tmp.substring(index+PARENT_WITH_SEPARATOR.length());
                    tmp = tmpFile.toString();
                }
            }
            incPath = new File(tmp);
        }

        if(incPath.toString().endsWith(PARENT)) {
            incPath = new File(incPath.toString().substring(0, incPath.toString().length()-PARENT.length()));
            incPath = incPath.getParentFile();
            if(incPath == null)
                incPath = new File(Config.getPathSeparator());
        }

        if( incPath.toString().indexOf(STAR) > -1 || incPath.toString().indexOf(WILDCARD) > -1) {
            PathCriteria pathCriteria = parsePath(incPath);
            if(incPath.toString().indexOf(SEPARATOR) > -1) {
                List<File> foundFiles  = null;
                if(pathCriteria.getCriteria().equals(String.valueOf(STAR))) {
                    foundFiles = new ArrayList<>();
                    foundFiles.add(new File(pathCriteria.getParentPath()));
                }
                else
                    foundFiles = findFiles(new File(pathCriteria.parentPath), pathCriteria.getCriteria(), false);
                if(pathCriteria.childPath.length() == 0)
                    return foundFiles;
                else {
                    List<File> outFiles = new ArrayList<>();
                    for(File f : foundFiles)
                        if(new File(f+Config.getPathSeparator()+pathCriteria.childPath).exists())
                            outFiles.add(new File(f+Config.getPathSeparator()+pathCriteria.childPath));

                    return outFiles;
                }
            }
            //just wildcard without separators
            else {
                if(incPath.toString().length() == 1) {
                    List<File> foundFiles = findFiles(new File(pathCriteria.parentPath), pathCriteria.getCriteria(), false);
                    if(pathCriteria.childPath.length() == 0)
                        return foundFiles;
                }

                return new ArrayList<File>();
            }
        }
        else {
            //no wildcards
            ArrayList<File> fileList = new ArrayList<>(1);
            fileList.add(incPath);
            return fileList;
        }
    }
733697
public static String getCategoryPath(String rootPath, String baseFolder) throws Exception {

        String base;
        if (rootPath.startsWith(CmsCategoryService.CENTRALIZED_REPOSITORY)) {
            base = CmsCategoryService.CENTRALIZED_REPOSITORY;
        } else {
            base = baseFolder;
            if (!base.endsWith("/")) {
                base += "/";
            }
            if (!base.startsWith("/")) {
                base = "/" + base;
            }
            int pos = rootPath.indexOf(base);
            if (pos < 0) {
                throw new Exception("Invalid category location \"" + rootPath + "\".");
            }
            base = rootPath.substring(0, pos + base.length());
        }
        return rootPath.substring(base.length());
    }
1098715
def getcwd(cls):
        
        if not hasattr(cls._tl, "cwd"):
            cls._tl.cwd = os.getcwd()
        return cls._tl.cwd
68451
function ftpCwd(inPath, cb) {
    ftp.raw.cwd(inPath, function(err) {
      if (err) {
        ftp.raw.mkd(inPath, function(err) {
          if (err) {
            log.error('Error creating new remote folder ' + inPath + ' --> ' + err);
            cb(err);
          } else {
            log.ok('New remote folder created ' + inPath.yellow);
            ftpCwd(inPath, cb);
          }
        });
      } else {
        cb(null);
      }
    });
  }
1331159
def absolute_git_root_dir(fpath=""):
    
    if len(fpath) == 0:
        dirname_str = os.getcwd()
    else:
        dirname_str = os.path.dirname(fpath)
    dirname_str = os.path.abspath(dirname_str)
    dirnames = dirname_str.split(os.sep)
    n = len(dirnames)
    for i in xrange(n):
        # is there a .git directory at this level?
        # FIXME hack
        basedir = "/" + os.path.join(*dirnames[0:n - i])
        gitdir = os.path.join(basedir, ".git")
        if os.path.exists(gitdir):
            return basedir
66990
public static Map<Component,File> findScopedInstancesDirectories( AbstractApplication absApp ) {

		Map<Component,File> result = new HashMap<> ();
		for( Component c : ComponentHelpers.findAllComponents( absApp.getGraphs())) {

			// Target?
			if( ! ComponentHelpers.isTarget( c ))
				continue;

			// Is there a resources directory?
			File dir = ResourceUtils.findInstanceResourcesDirectory( absApp.getDirectory(), c );
			if( ! dir.exists())
				continue;

			result.put( c, dir );
		}

		return result;
	}
776323
def get_path(dest, file, cwd = None):
	""""""
	if callable(dest):
		return dest(file)

	if not cwd:
		cwd = file.cwd
	if not os.path.isabs(dest):
		dest = os.path.join(cwd, dest)

	relative = os.path.relpath(file.path, file.base)
	return os.path.join(dest, relative)
557741
function (filePath) {
        var name = path.relative(this.opts.cwd, filePath);

        name = path.join(path.dirname(name), path.basename(name, this.opts.extension));

        return name;
    }
11269
def cwd():
    """"""
    cwd = os.environ.get("BE_CWD")
    if cwd and not os.path.isdir(cwd):
        sys.stderr.write("ERROR: %s is not a directory" % cwd)
        sys.exit(lib.USER_ERROR)
    return cwd or os.getcwd().replace("\\", "/")
1262785
def get_root_path(self, path):
        """"""
        # Look at the directories present in the current working directory. In
        # case a .svn directory is present, we know we are in the root directory
        # of a Subversion repository (for Subversion 1.7.x). In case no
        # repository specific folder is found, and the current directory has a
        # parent directory, look if a repository specific directory can be found
        # in the parent directory.
        while path != '/':
            if '.svn' in os.listdir(path):
                return path
            path = os.path.abspath(os.path.join(path, os.pardir))

        # No Subversion repository found.
        return None
1304832
protected String getRelativePath(String ancestor, String rootPath) {

        String result = rootPath.substring(ancestor.length());
        result = CmsStringUtil.joinPaths("/", result, "/");
        return result;
    }
864790
function load(inPath)
{
  var keys;

  // Group description file can be specified as relative to CWD
  var configFilePath = pathlib.resolve(process.cwd(),inPath);

  // Paths are relative to the config file (inPath) + /public by default
  var configDir = pathlib.dirname(configFilePath);
  var baseDir = pathlib.resolve(configDir,'public');

  // Load the JSON description of the groups
  var input = JSON.parse(stripJsonComments(fs.readFileSync(configFilePath,'utf8')));
  var ret = {};

  // 1. Resolve everything to absolute paths

  // 1a. Root file dirs -- relative to the config file
  ret.rootFileDirs = (input.rootFileDirs||[]).map(function(path) {
    return pathlib.resolve(configDir, path);
  });

  // 1b. Static file dirs -- relative to the config file
  ret.staticFileDirs = {};
  keys = Object.keys(input.staticFileDirs||{});
  keys.forEach(function(key) {
    var paths = input.staticFileDirs[key];
    if ( !util.isArray(paths) )
      paths = [paths];

    ret.staticFileDirs[key] = paths.map(function(path) {
      return pathlib.resolve(configDir, path);
    });
  });

  // 1c. Groups
  keys = Object.keys(input.groups||{});

  // Loop over each group definition
  ret.groups = {};
  keys.forEach(function(groupName) {
    var group = input.groups[groupName];
    var subKeys = Object.keys(group);

    var newGroup = {};

    // You can override the base directory per-group
    if ( group.baseDir )
    {
      var paths = group.baseDir;
      if ( !util.isArray(paths) )
        paths = [paths];

      newGroup.customBaseDir = true;
      newGroup.baseDir = paths.map(function(path) {
        // If baseDir is specified for the group, it's relative to the location of the asset file
        return pathlib.resolve(configDir, path);
      });
    }
    else
    {
      newGroup.customBaseDir = false;
      newGroup.baseDir = [baseDir];
    }

    newGroup.include = group.include || [];

    // Loop over each key in the group definition
    subKeys.forEach(function(subKey) {
      if ( SPECIAL_KEYS.indexOf(subKey) >= 0 )
      {
        // We've already dealt with these
        return;
      }

      if ( HANDLER_KEYS.indexOf(subKey) === -1 )
      {
        throw new Error('Unknown group property: '+ subKey);
      }

      // Resolve file names into absolute paths
      newGroup[subKey] = (group[subKey]||[]).map(function(filename) {
        return resolveFile(newGroup.baseDir, !newGroup.customBaseDir, filename, subKey);
      });
    });

    ret.groups[groupName] = newGroup;
  });

  // 2. Process each group into a flat list of the file names needed
  keys = Object.keys(ret.groups);
  keys.forEach(function(groupName) {
    var flattened = _flatten(ret.groups, groupName);

    // Remember if we're supposed to save the output or not for compliling
    flattened.saveOutput = input.groups[groupName].saveOutput !== false;

    ret.groups[groupName] = flattened;
  });

  return ret;
}
890401
def abspath(relpath, root=None):
    """"""
    root = root or cwd()
    if op.isfile(root):
        root = op.dirname(root)
    return op.abspath(op.join(root, relpath))
1113011
function findPath(path, directories) {
  var cwd = directories[0];

  if (!cwd) {
    return null;
  }

  return findup(path, {cwd: cwd}) || findPath(path, slice.call(directories, 1));
}
286610
public static Path pathForFileInRoot(
            final File rootDir,
            final File file
    )
    {
        String filePath = file.getAbsolutePath();
        String rootPath = rootDir.getAbsolutePath();
        if (!filePath.startsWith(rootPath)) {
            throw new IllegalArgumentException("not a file in the root directory: " + file);
        }
        return pathForRelativeFilepath(filePath.substring(rootPath.length()));
    }
483829
def pwd(self, **kwargs):
            

            b_node  = False
            node    = 0
            for key,val in kwargs.items():
                if key == 'node':
                    b_node  = True
                    node    = int(val)

            str_path = self.cwd()
            if b_node:
                l_path      = str_path.split('/')
                if len(l_path) >= node+1:
                    str_path    = str_path.split('/')[node]
            return str_path
588962
def __root_path(self):
        
        if self.root_path is not None:
            if os.path.isdir(self.root_path):
                sys.path.append(self.root_path)
                return
            raise RuntimeError('EverNode requires a valid root path.'
                               ' Directory: %s does not exist'
                               % (self.root_path))