diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-01 16:09:41 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-01 16:09:41 +0200 |
commit | 6c9ba0428041d5316871245be38c13faa0107026 (patch) | |
tree | 98e9246ce0516f0eb54b6893ce8398d4db42baf3 /runtime/doc | |
parent | d14fd5285e491a39028c4b4722ddbe7c9dfa9bb2 (diff) | |
download | vim-git-6c9ba0428041d5316871245be38c13faa0107026.tar.gz |
patch 8.2.0875: getting attributes for directory entries is slowv8.2.0875
Problem: Getting attributes for directory entries is slow.
Solution: Add readdirex(). (Ken Takata, closes #5619)
Diffstat (limited to 'runtime/doc')
-rw-r--r-- | runtime/doc/eval.txt | 59 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 1 |
2 files changed, 58 insertions, 2 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 7582a2724..421c09131 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2676,6 +2676,7 @@ rand([{expr}]) Number get pseudo-random number range({expr} [, {max} [, {stride}]]) List items from {expr} to {max} readdir({dir} [, {expr}]) List file names in {dir} selected by {expr} +readdirex({dir} [, {expr}]) List file info in {dir} selected by {expr} readfile({fname} [, {type} [, {max}]]) List get list of lines from file {fname} reg_executing() String get the executing register name @@ -7840,11 +7841,11 @@ rand([{expr}]) *rand()* *random* :echo rand(seed) :echo rand(seed) % 16 " random number 0 - 15 < - *readdir()* -readdir({directory} [, {expr}]) +readdir({directory} [, {expr}]) *readdir()* Return a list with file and directory names in {directory}. You can also use |glob()| if you don't need to do complicated things, such as limiting the number of matches. + The list will be sorted (case sensitive). When {expr} is omitted all entries are included. When {expr} is given, it is evaluated to check what to do: @@ -7854,6 +7855,7 @@ readdir({directory} [, {expr}]) added to the list. If {expr} results in 1 then this entry will be added to the list. + The entries "." and ".." are always excluded. Each time {expr} is evaluated |v:val| is set to the entry name. When {expr} is a function the name is passed as the argument. For example, to get a list of files ending in ".txt": > @@ -7872,6 +7874,59 @@ readdir({directory} [, {expr}]) Can also be used as a |method|: > GetDirName()->readdir() < +readdirex({directory} [, {expr}]) *readdirex()* + Extended version of |readdir()|. + Return a list of Dictionaries with file and directory + information in {directory}. + This is useful if you want to get the attributes of file and + directory at the same time as getting a list of a directory. + This is much faster than calling |readdir()| then calling + |getfperm()|, |getfsize()|, |getftime()| and |getftype()| for + each file and directory especially on MS-Windows. + The list will be sorted by name (case sensitive). + + The Dictionary for file and directory information has the + following items: + group Group name of the entry. (Only on Unix) + name Name of the entry. + perm Permissions of the entry. See |getfperm()|. + size Size of the entry. See |getfsize()|. + time Timestamp of the entry. See |getftime()|. + type Type of the entry. + On Unix, almost same as |getftype()| except: + Symlink to a dir "linkd" + Other symlink "link" + On MS-Windows: + Normal file "file" + Directory "dir" + Junction "junction" + Symlink to a dir "linkd" + Other symlink "link" + Other reparse point "reparse" + user User name of the entry's owner. (Only on Unix) + On Unix, if the entry is a symlink, the Dictionary includes + the information of the target (except the "type" item). + On MS-Windows, it includes the information of the symlink + itself because of performance reasons. + + When {expr} is omitted all entries are included. + When {expr} is given, it is evaluated to check what to do: + If {expr} results in -1 then no further entries will + be handled. + If {expr} results in 0 then this entry will not be + added to the list. + If {expr} results in 1 then this entry will be added + to the list. + The entries "." and ".." are always excluded. + Each time {expr} is evaluated |v:val| is set to a Dictionary + of the entry. + When {expr} is a function the entry is passed as the argument. + For example, to get a list of files ending in ".txt": > + readdirex(dirname, {e -> e.name =~ '.txt$'}) +< + Can also be used as a |method|: > + GetDirName()->readdirex() +< *readfile()* readfile({fname} [, {type} [, {max}]]) Read file {fname} and return a |List|, each line of the file diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 2642e0b39..0793a04ea 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -791,6 +791,7 @@ System functions and manipulation of files: hostname() name of the system readfile() read a file into a List of lines readdir() get a List of file names in a directory + readdirex() get a List of file information in a directory writefile() write a List of lines or Blob into a file Date and Time: *date-functions* *time-functions* |