Normalize file path and always return relative path,

@param {string} filepath user's path
@param {string} baseDir source directory
@returns {string}
974091
function normalizeWatchFilePath (filepath, baseDir) {
  const { isAbsolute, relative } = require('path')
  if (isAbsolute(filepath)) {
    return relative(baseDir, filepath)
  }
  return filepath
}
1141071
function relative(dir, file) {
    var isDirectory = file.slice(-1) === '/';
    return normalize(path.relative(dir, file)) + (isDirectory? '/': '');
}
447791
function (basepath, action, recursive) {
  var isDirectory = function (target) {
    return fs.statSync(target).isDirectory();
  };
  var nextLevel = function (subpath) {
    _.each(fs.readdirSync(path.join(basepath, subpath)), function (filename) {
      if (isDirectory(path.join(basepath, (filename = path.join(subpath, filename))))) {
        if (recursive) {
          nextLevel(filename);
        }
      } else {
        action(filename);
      }
    });
  };
  nextLevel('./');
}
833230
function normalizeResourcePath(path) {
    path = path || "";
    while (path.startsWith("/"))
        path = path.slice(1);
    while (path.endsWith("/"))
        path = path.slice(0, -1);
    return path;
}
1199531
def setFilepath(self, filepath):
        
        if not filepath:
            self._filepathEdit.setText('')
            return
        
        if self.normalizePath():
            filepath = os.path.normpath(nativestring(filepath))
        else:
            filepath = os.path.normpath(nativestring(filepath)).replace('\\', '/')
            
        self._filepathEdit.setText(filepath)
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;
}
865962
function isDirectory(filePath) {
	var isDir = false;
	try {
		var absolutePath = path.resolve(filePath);
		isDir = fs.lstatSync(absolutePath).isDirectory();
	} catch (e) {
		isDir = e.code === 'ENOENT';
	}
	return isDir;
}
288236
function () {
            var filePath = this.getFileName();
            if (!this.__fileContentsCache && filePath) {
                // Leave the stage early when 'Unknown' is passed
                // this would otherwise raise an exception when
                // open_basedir is enabled.
                if (filePath === "Unknown") {
                    return null;
                }

                // Return null if the file doesn't actually exist.
                if (!fs.existsSync(filePath)) {
                    if (process.env.NVM_DIR && process.versions.node) {
                        filePath = path.join(process.env.NVM_DIR, 'src/node-v' + process.versions.node, 'lib', filePath);
                        if (!fs.existsSync(filePath)) {
                            return null;
                        }
                    } else {
                        return null;
                    }
                }

                this.__fileContentsCache = fs.readFileSync(filePath, 'utf-8');
            }

            return this.__fileContentsCache;
        }
252741
function(src, filepath) {
					/*
					return '// Source: ' + filepath + '\n' +
						src.replace(/##VERSION##/g, '##FOUND##');
					*/
					src = src.replace(/##ID##/g, options.id);
					src = src.replace(/##VERSION##/g, options.version);
					src = src.replace(/##CODEBASE##/g, options.extension.updateUrl);
					return src;
				}
1184739
function normalizePath (path, basePath) {
  var joined = nodepath.join(basePath || '/', path || '');
  var normalized = nodepath.normalize(joined);

  return (normalized !== '/' ? normalized : null);
}
377044
function (url, baseDir, done) {
  resolve(url, {
    basedir: baseDir,
    extensions: [ '.scss', '.sass', '.css' ],
    pathFilter: function (pkg, absPath, relativePath) {
      var globbedPath = buildSassGlob(absPath);
      var paths = glob.sync(globbedPath);
      var resolvedPath = paths && paths[0];
      if (resolvedPath) {
        return path.join(path.dirname(relativePath), path.basename(resolvedPath));
      }
    }
  }, function (err, file) {
    if (err) return done(err);

    // Strip the extension so .css gets evaluated properly as .scss
    file = file.replace(/\.(js|(sa|sc|c)ss)$/, '');
    done(null, file);
  });
}
850758
function createIgnoreResult(filePath, baseDir) {
    let message;
    const isHidden = /^\./u.test(path.basename(filePath));
    const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules");
    const isInBowerComponents = baseDir && path.relative(baseDir, filePath).startsWith("bower_components");

    if (isHidden) {
        message = "File ignored by default.  Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override.";
    } else if (isInNodeModules) {
        message = "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override.";
    } else if (isInBowerComponents) {
        message = "File ignored by default. Use \"--ignore-pattern '!bower_components/*'\" to override.";
    } else {
        message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override.";
    }

    return {
        filePath: path.resolve(filePath),
        messages: [
            {
                fatal: false,
                severity: 1,
                message
            }
        ],
        errorCount: 0,
        warningCount: 1,
        fixableErrorCount: 0,
        fixableWarningCount: 0
    };
}
1140098
function normalizeFilepath(filepath) {
    filepath = filepath.replace(/\\/g, "/");
    filepath = filepath.replace(/^\.\//, "");
    return filepath;
}
1058162
async function _filesInDirectory(dirPath, options) {
  const basedir = options.basedir || getCallingDir();
  const resolvedDirPath = basedir?path.resolve(basedir, dirPath):dirPath;
  let xExt = _getExtensionRegEx(options.extension || settings.get('extensions'));

  try {
    const files = (await readDir(resolvedDirPath));
    if (options.rescursive) {
      const dirs = chain(await Promise.all(chain(files)
        .map(fileName=>path.resolve(resolvedDirPath, fileName))
        .map(async (file)=>{
          const stat = await lstat(file);
          if (stat.isDirectory()) return file;
        })
        .value())).filter(file=>file);
      if (dirs.value().length) files.push(...(await Promise.all(
        dirs.map(dirPath=>_filesInDirectory(dirPath, options)).value()
      )));
    }
    return chain(files)
      .flattenDeep()
      .filter(fileName=>xExt.test(fileName))
      .map(fileName=>path.resolve(resolvedDirPath, fileName))
      .value();
  } catch (err) {
    return [];
  }
}
602627
function calcRelPath(filePath, linkPath) {
    filePath = filePath.replace(`\\`, `/`);
    linkPath = linkPath.replace(`\\`, `/`);
    let RelPath = '',
        linkPathList = linkPath.split('/'),
        filePathList = filePath.split('/'),
        idx = 0;
    console.log(`File Path : ${filePath}, link path : ${linkPath}`);
    for (let i = 1; i < filePathList.length - 1; i++) {
        idx = i;
        if (filePathList[i] === linkPathList[i])
            break;
        RelPath += '../';
    }

    if (RelPath.length === 0) {
        RelPath += './';
        idx += 1;
    }

    if (idx === 0) idx += 1;

    for (let i = idx; i < linkPathList.length - 1; i++) {
        RelPath += linkPathList[i] + '/';
    }

    RelPath += linkPathList[linkPathList.length - 1];
    console.log(`RelPath : ${RelPath}`);
    return RelPath;
}
1049289
private static String getRelativePath(final String basePath, final String refPath, final String sep) {
        final StringBuilder upPathBuffer = new StringBuilder(128);
        final StringBuilder downPathBuffer = new StringBuilder(128);
        final StringTokenizer mapTokenizer = new StringTokenizer(normalizePath(basePath, File.separator), File.separator);
        final StringTokenizer topicTokenizer = new StringTokenizer(normalizePath(refPath, File.separator), File.separator);

        while (mapTokenizer.countTokens() > 1
                && topicTokenizer.countTokens() > 1) {
            final String mapToken = mapTokenizer.nextToken();
            final String topicToken = topicTokenizer.nextToken();
            boolean equals;
            if (OS_NAME.toLowerCase().contains(OS_NAME_WINDOWS)) {
                //if OS is Windows, we need to ignore case when comparing path names.
                equals = mapToken.equalsIgnoreCase(topicToken);
            } else {
                equals = mapToken.equals(topicToken);
            }

            if (!equals) {
                if (mapToken.endsWith(COLON) ||
                        topicToken.endsWith(COLON)) {
                    //the two files are in different disks under Windows
                    return refPath;
                }
                upPathBuffer.append("..");
                upPathBuffer.append(sep);
                downPathBuffer.append(topicToken);
                downPathBuffer.append(sep);
                break;
            }
        }

        while (mapTokenizer.countTokens() > 1) {
            mapTokenizer.nextToken();

            upPathBuffer.append("..");
            upPathBuffer.append(sep);
        }

        while (topicTokenizer.hasMoreTokens()) {
            downPathBuffer.append(topicTokenizer.nextToken());
            if (topicTokenizer.hasMoreTokens()) {
                downPathBuffer.append(sep);
            }
        }

        return upPathBuffer.append(downPathBuffer).toString();
    }
1170311
function (filePath) {

            var pos = filePath.lastIndexOf("\\");
            if (pos !== -1) {
                filePath = filePath.substr(pos + 1);
            }

            pos = filePath.lastIndexOf("/");
            if (pos !== -1) {
                filePath = filePath.substr(pos + 1);
            }

            return filePath;
        }