拷贝目录
@param {*String} srcPath 需要拷贝的目录绝对路径
@param {*String} desPath 目标绝对路径
@param {*String} relative 调用时请忽略，函数内部区别是否递归开始
765189
function copyDir(srcPath, desPath, relative) {
    if(relative == undefined){
        relative = srcPath;
    }

    fs.readdir(srcPath, function (err, files) {
        files.forEach(function (fileName) {
            fs.stat(path.join(srcPath, fileName), function (err, stats) {
                if (err) {
                    console.log('[error] ', err);
                    return;
                }
                if (stats.isFile()) {
                    var relativePath = path.relative(relative, srcPath);
                    var replace = { win32: '..\\', linux: '../' };

                    var srcFile = path.normalize(srcPath + '/' + fileName);
                    var desFile = path.normalize(path.join(desPath,
                        relativePath.replace(replace[os.platform])) + '/' + fileName);
                    //console.log('src file:', srcFile);
                    //console.log('des file:', desFile);
                    createDir(srcFile,desFile);

                } else if (stats.isDirectory()) {
                    //第三个参数用于区分是否是递归开始，并且计算目标路径相对于给定路径的相对位置
                    copyDir(path.join(srcPath,fileName),desPath,relative);
                }
            });
        });
    });
}
140312
public static File getRelativePath(final File relativePath) {
        final String p = getRelativePathForPath(relativePath.getPath(), File.separator);
        return p != null ? new File(p) : null;
    }
752322
public static String getRelativePath(File file, File srcDir) {

		String base = srcDir.getPath();
		String filePath = file.getPath();

		String relativePath = new File(base).toURI()
				.relativize(new File(filePath).toURI()).getPath();
		return relativePath;
	}
598789
public void copyFile(final RelativeResource src, final RelativeResource dest)
		throws IOException {
		if (src.equals(dest)) {
			return;
		}
		LOG.debug("复制文件从 {} 到 {}", src, dest);
		File srcFile = getResource(src).getFile();
		if (!srcFile.exists()) {
			throw new FileNotFoundException(srcFile.getAbsolutePath());
		}
		File destFile = getResource(dest).getFile();
		deleteOldFile(destFile);
		FileUtils.copyFile(srcFile, destFile);
	}
444805
def relativesymlink(src_file, dest_file):
    
    # Perform relative symlinking
    try:
        print(os.path.relpath(src_file), os.path.relpath(dest_file))
        os.symlink(
            # Find the relative path for the source file and the destination file
            os.path.relpath(src_file),
            os.path.relpath(dest_file)
        )
    # Except os errors
    except OSError as exception:
        # If the os error is anything but directory exists, then raise
        if exception.errno != errno.EEXIST:
            raise
1105399
private File getFileFromPath(final String path) {
        File result = (path != null) ? new File(path) : null;
        // AS7-1752 see if a non-existent relative path exists relative to the home dir
        if (result != null && homeDir != null && !result.exists() && !result.isAbsolute()) {
            File relative = new File(homeDir, path);
            if (relative.exists()) {
                result = relative;
            }
        }
        return result;
    }
640239
function (path, next) {
      var t$ = this

      var files = typeof path === 'string' ? [path] : path

      for (var i = 0; i < files.length; i++) {
        var name = files[i].replace(/^\s|\s$/g, '')
        var att = name.split('.')
        var ext = att[att.length - 1].toLowerCase()
        var isCSS = ext === 'css'
        var tag = isCSS ? 'link' : 'script'
        var attr = isCSS ? ' type=\'text/css\' rel=\'stylesheet\' ' : ' language=\'javascript\' type=\'text/javascript\' '
        var link = (isCSS ? 'href' : 'src') + '=\'' + t$.includePath + name + '\''
        if ($(tag + '[' + link + ']').length === 0) {
          if ($.inArray(path, t$.cache) === -1) {
            t$.cache.push(path)
            var content = '<' + tag + attr + link + '></' + tag + '>'
            isCSS ? $('head').append(content) : $('head').append(content)
          }
        }
      }
      next && next()
    }
803199
function walkTree(dirPath) {
    let filesindir = [];
    return new Promise((res, rej) => {
        if (dirPath.match(/node_modules|.git|bower|LICENCE|tree.json/)) {
            rej([]);
        }

        const relative = `${dirPath}/`,
            readPath = dirPath === '.' ? ROOT + '/' : dirPath + '/';

        readdir(path.resolve(readPath))
            .then(files => {
                files.map(async(i) => {
                    let file;
                    if (fs.statSync(path.join(relative, i)).isDirectory()) {
                        file = {
                            name: i,
                            type: 'dir',
                            path: `${relative}${i}`,
                            files: {}
                        }
                    } else {
                        file = {
                            id: id,
                            name: i,
                            type: 'file',
                            path: `${relative}${i}`,
                            imports: [],
                            exports: []
                        }
                        AllFiles[id++] = file;
                    }
                    filesindir.push(file);
                })
                res(filesindir);
            })
            .catch(err => {
                console.error(err);
                rej([]);
            })
    })
}
178627
function (path) {
                //There has to be an easier way to do this.
                var i, part, ary,
                    firstChar = path.charAt(0);

                if (firstChar !== '/' &&
                        firstChar !== '\\' &&
                        path.indexOf(':') === -1) {
                    //A relative path. Use the current working directory.
                    path = xpcUtil.cwd() + '/' + path;
                }

                ary = path.replace(/\\/g, '/').split('/');

                for (i = 0; i < ary.length; i += 1) {
                    part = ary[i];
                    if (part === '.') {
                        ary.splice(i, 1);
                        i -= 1;
                    } else if (part === '..') {
                        ary.splice(i - 1, 2);
                        i -= 2;
                    }
                }
                return ary.join('/');
            }
1079155
function(src, dest) {
    var contents,
        srcExists = fs.existsSync(src),
        destExists = fs.existsSync(dest),
        stats = srcExists && fs.statSync(src),
        isDirectory = srcExists && stats.isDirectory();

    if (srcExists) {
        if (isDirectory) {
            if (!destExists) {
                fs.mkdirSync(dest);
            }
            fs.readdirSync(src).forEach(function(childItemName) {
                copyRecursiveSync(path.join(src, childItemName),
                    path.join(dest, childItemName));
            });
        } else {
            contents = fs.readFileSync(src);
            fs.writeFileSync(dest, contents);
        }
    }
}
221151
function (destPath, srcPaths, options) {
    let stream,
        b,
        finalPaths = [];
    return new Promise(function (resolve, reject) {
        _.each(srcPaths, function (path) {
            // deal with file globs
            if (glob.hasMagic(path)) {
                glob.sync(path).forEach((p) => {
                    p = utils.scopePaths(p);
                    finalPaths.push(p);
                });
            } else {
                path = utils.scopePaths(path);
                finalPaths.push(path);
            }
        });

        // add required parameters for watchify
        options.cache = {};
        options.packageCache = {};

        options.debug = options.watch;

        b = browserify(options);

        b.transform(envify({
            _: 'purge',
            NODE_ENV: options.env
        }), {global: true});

        // must add each path individual unfortunately.
        finalPaths.forEach(function (path) {
            b.add(path);
        });

        options.ignore.forEach((file) => {
            b.ignore(file);
        });
        options.exclude.forEach((file) => {
            b.exclude(file);
        });

        // require global files
        _.each(options.requires, function (path, id) {
            // options.requires can be an array of strings or an object
            id = typeof id == "string" ? id : path;
            b.require(path, {expose: id});
        });

        if (options.watch) {
            b.plugin(watchify);
            // re-bundle when updated
            b.on('update', function () {
                console.log('file updated!');
                b.bundle();
            });
        }


        b.on('bundle', function (stream) {
            console.log('browserifying bundle...');
            writeBrowserifyBundleStreamToFile(stream, destPath)
                .then(function () {
                    console.log('done browserifying bundle!');
                    resolve();
                })
                .catch(function (e) {
                    console.log('browserifying failed');
                    console.log(e);
                    reject(e);
                });
        });

        stream = b.bundle();

    }.bind(this));
}
708407
@SuppressWarnings("WeakerAccess")
    @NonNull
    public static Uri getUriForFile(@NonNull Context context, @NonNull Directory directory, @NonNull String relativePath) {
        final Uri.Builder builder = new Uri.Builder()
                .scheme(ContentResolver.SCHEME_CONTENT)
                .authority(getAuthority(context))
                .appendPath(directory.name().toLowerCase());
        for (String segment : relativePath.split(Pattern.quote(File.separator))) {
            if (segment.length() > 0) {
                builder.appendPath(segment);
            }
        }
        return builder.build();
    }
171475
def relative_path_from(root_path, path)
      project_path = Pathname.new(path)
      return project_path if project_path.relative?
      project_path.relative_path_from(root_path)
    end
399648
function(filePath, currentPath){
	if(/^(?:\/|[a-zA-Z]:(?:\/|\\))/.test(filePath)){ // Is the path absolute?
		filePath = path.normalize(filePath);
	}else{ // Relative paths need to be resolved first
		filePath = path.resolve(currentPath, filePath);
	}
	return filePath;
}
180925
def ensure_dir_path(self, path, relative=False):
        
        if not relative:
            rel_path = self.relpath(path)
        else:
            rel_path = path

        # Locator
        if self.is_locator(rel_path, relative=True):
            path = path.rstrip('/')

        # Directory
        elif rel_path:
            path = path.rstrip('/') + '/'
        # else: root
        return path
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);
    }
  }
}
664537
public void setRelativePath(QPath relPath) {
        if (relPath != null && relPath.isAbsolute()) {
            throw new IllegalArgumentException("relPath must be relative");
        }
        this.relPath = relPath;
    }