Skip to main content
Module

x/denops_std/function/vim/mod.ts>readdirex

📚 Standard module for denops.vim
Go to Latest
function readdirex
import { readdirex } from "https://deno.land/x/denops_std@v6.4.0/function/vim/mod.ts";

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 by default be sorted by name (case sensitive), the sorting can be changed by using the optional {dict} argument, see readdir().

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$'})

For example, to get a list of all files in the current directory without sorting the individual entries:

readdirex(dirname, '1', #{sort: 'none'})

Can also be used as a method:

GetDirName()->readdirex()

Parameters

denops: Denops
directory: unknown
optional
expr: unknown
optional
dict: unknown

Returns

Promise<unknown[]>