Add all files in the tree. If the "path" is a file,
    only that file will be added.

    :param path: File or directory
    :return:
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)
1354536
def add_path(self, path):
        """"""
        if not os.path.exists(path):
            raise RuntimeError('Path does not exists: %s.' % path)
        self.paths.append(path)
256246
def list_files(dir_path, recursive=True):
    

    for root, dirs, files in os.walk(dir_path):
        file_list = [os.path.join(root, f) for f in files]
        if recursive:
            for dir in dirs:
                dir = os.path.join(root, dir)
                file_list.extend(list_files(dir, recursive=True))
        return file_list
73316
def do_put(self, from_path, to_path):
        
        from_file = open(os.path.expanduser(from_path), "rb")

        self.n.put(self.current_path + "/" + from_path, to_path)
1146926
def register(self, path):
        
        if path not in self._paths:
            LOG.debug('%r: registering %r', self, path)
            self._paths.add(path)
419612
def mkdir(self, path):
        
        if not os.path.exists(path):
            os.makedirs(path)
1094627
def add_path(self, path):
        # type: (_BaseSourcePaths, str) -> None
        
        if isinstance(path, pathlib.Path):
            self._paths.append(path)
        else:
            self._paths.append(pathlib.Path(path))
1076418
def addFile(self, path, msg=""):
        """"""
        item = Item.from_path(repo=self.repo, path=path)
        self.addItem(item)
1160902
def add_load_path(path)
      if path = parse_load_paths(path).first # only accept first one.
        self.load_paths << path
        self.load_paths.uniq!
        return reload(true)  # Load Paths have changed so force a reload
      end
      false
    end
1097098
def fill(self, paths):
        
        for path in paths:
            tree = self.tree
            parts = tuple(path.split('/'))
            dir_parts = parts[:-1]
            built = ()
            for part in dir_parts:
                self.cache[built] = tree
                built += (part, )
                parent = tree
                tree = parent.folders.get(part, empty)
                if tree is empty:
                    tree = parent.folders[part] = TreeItem(name=built, folders={}, files=set(), parent=parent)

            self.cache[dir_parts] = tree
            tree.files.add(parts[-1])
22439
def mkdir(path):
    
    try:
        os.makedirs(path)
        # sanity check
        if not os.path.isdir(path):  # pragma: no cover
            raise IOError('path is not a directory')
    except OSError as e:
        # EEXIST
        if e.errno == 17 and os.path.isdir(path):
            return
        raise
767221
def append_path(path)
      self.config = hash_reassoc(config, :paths) do |paths|
        path = File.expand_path(path, config[:root]).freeze
        paths.push(path)
      end
    end
248080
def makedir(path):
    
    if path is not None and not os.path.exists(path):
        os.makedirs(path)
591781
def AddDir(self, dirpath):
    
    if dirpath not in self._dirs:
      self._dirs.add(dirpath)
      return True
    return False
1035367
def addPath(rel_path, prepend=False):
    
    path = lambda *paths: os.path.abspath(
        os.path.join(os.path.dirname(__file__), *paths)) + '/'
    if prepend:
      return sys.path.insert(0, path(rel_path))
    return sys.path.append(path(rel_path))
348187
def add(self, path):
        
        if not path.startswith(os.sep):
            raise ValueError("Non-absolute path '{}'".format(path))
        path = path.rstrip(os.sep)
        while True:
            self._paths[path] = None
            path, _ = os.path.split(path)
            if path == os.sep:
                break
104088
def _AddParentDirectories(self, path):
    
    path_segments = self.file_system.SplitPath(path)
    for segment_index in range(len(path_segments)):
      parent_path = self.file_system.JoinPath(path_segments[:segment_index])
      file_entry = self.file_system.GetFileEntryByPath(parent_path)
      if file_entry and not file_entry.IsDirectory():
        raise ValueError(
            'Non-directory parent file entry: {0:s} already exists.'.format(
                parent_path))

    for segment_index in range(len(path_segments)):
      parent_path = self.file_system.JoinPath(path_segments[:segment_index])
      if not self.file_system.FileEntryExistsByPath(parent_path):
        self.file_system.AddFileEntry(
            parent_path, file_entry_type=definitions.FILE_ENTRY_TYPE_DIRECTORY)