Ensure the path that is passed is only the name of the file and not a path
490501
protected boolean isBasename(String potentialPath){
        if (ALLOW_VIEW_NAME_PATH_TRAVERSAL) {
            return true;
        } else {
            if (potentialPath.contains("\\") || potentialPath.contains("/")) {
                // prevent absolute path and folder traversal to find scripts
                return false;
            }
            
            return true;
        }
    }
895949
def join_path(fname:PathOrStr, path:PathOrStr='.')->Path:
    ""
    return Path(path)/Path(fname)
573914
def ensurepath(path_, verbose=None):
    
    if verbose is None:
        verbose = VERYVERBOSE
    return ensuredir(path_, verbose=verbose)
1095047
def filename_from_path(path):
    
    head, tail = ntpath.split(path)
    return head, tail or ntpath.basename(head)
1371978
def ValidateVfsPath(path):
  """"""

  components = (path or "").lstrip("/").split("/")
  if not components:
    raise ValueError("Empty path is not a valid path: %s." %
                     utils.SmartStr(path))

  if components[0] not in ROOT_FILES_WHITELIST:
    raise ValueError(
        "First path component was '%s', but has to be one of %s" %
        (utils.SmartStr(components[0]), ", ".join(ROOT_FILES_WHITELIST)))

  return True
284718
def get_calling_file(file_path=None, result='name'):
    
    # Get full path of calling python script
    if file_path is None:
        path = inspect.stack()[1][1]
    else:
        path = file_path

    name = path.split('/')[-1].split('.')[0]
    if result == 'name':
        return name
    elif result == 'path':
        return path
    else:
        return path, name
218684
def _safe_path(filepath, can_be_cwl=False):
    """"""
    # Should not be in ignore paths.
    if filepath in {'.gitignore', '.gitattributes'}:
        return False

    # Ignore everything in .renku ...
    if filepath.startswith('.renku'):
        # ... unless it can be a CWL.
        if can_be_cwl and filepath.endswith('.cwl'):
            return True
        return False

    return True
959288
function(filepath) {
    var pieces = _.last(filepath.split('/')).split('.');
    var name   = _(pieces).without(_.last(pieces)).join('.'); // strips file extension
    if (name.charAt(0) === '_') {
      name = name.substr(1, name.length); // strips leading _ character
    }
    return name;
  }
1189572
def is_root_path(self, filename):
        """"""
        test_filename = filename + '/'
        for root_dir in self.root_dirs:
            if test_filename.startswith(root_dir):
                return True
        return False
645859
def which(filename, env=None):
    ''''''

    # Special case where filename contains an explicit path.
    if os.path.dirname(filename) != '' and is_executable_file(filename):
        return filename
    if env is None:
        env = os.environ
    p = env.get('PATH')
    if not p:
        p = os.defpath
    pathlist = p.split(os.pathsep)
    for path in pathlist:
        ff = os.path.join(path, filename)
        if is_executable_file(ff):
            return ff
    return None
246048
def optional_file_like(path):
    
    if (os.path.exists(path) and not (os.path.isfile(path) or
                                      stat.S_ISFIFO(os.stat(path).st_mode) or
                                      stat.S_ISCHR(os.stat(path).st_mode))):
        raise ValidationFailed(
            '{} is not a valid file, character device, or fifo.'.format(path))
850690
def _normpath(self, pathname):
        ""
        if pathname == '/':
            pathname = ''
        elif pathname.endswith('/'):
            pathname = pathname[:-1]
        assert not pathname.endswith('/'), pathname
        return pathname
1030329
function filterPath(absPath) {
		var relPath = path.relative(launchFolder, absPath)
		var result = excludeList.every(checkExclusion)

		return result

		function checkExclusion(exclusion) { // true: keep the path
			return relPath.substring(0, exclusion.length) != exclusion
		}
	}
827435
function path2FolderName(filePath, keepTailSlash){
		var pathSegs = filePath.split("/");
		pathSegs.splice(pathSegs.length -1, 1);
		return keepTailSlash ? pathSegs.join("/") + "/" : pathSegs.join("/");
	}
201434
def clean_path(p):
    
    p = os.path.expanduser(p)
    p = os.path.expandvars(p)
    p = os.path.abspath(p)
    return p
516894
def _clean_filepath(self, filepath):
        
        if (os.path.isdir(filepath) and
                os.path.isfile(os.path.join(filepath, '__init__.py'))):

            filepath = os.path.join(filepath, '__init__.py')

        if (not filepath.endswith('.py') and
                os.path.isfile(filepath + '.py')):
            filepath += '.py'
        return filepath
432300
def isignored(self, relpath, directory=False):
    """"""
    relpath = self._relpath_no_dot(relpath)
    if directory:
      relpath = self._append_trailing_slash(relpath)
    return self.ignore.match_file(relpath)