Types
Criterias = tuple[path: string, patterns, extensions: seq[string], regexPatterns: seq[Regex], size: tuple[min, max: FSize], bySize: bool]
FileFinder = ref object path: string info: FileInfo
FileSizeOp {.pure.} = enum EQ = "==", NE = "!=", LT = "<", GT = ">", LTE = "<=", GTE = ">="
FileSizeUnit {.pure.} = enum Bytes = "Bytes", Kilobytes = "KB", Megabytes = "MB", Gigabytes = "GB", Terabytes = "TB"
Filters = tuple[isRecursive: bool, ignoreHiddenFiles: bool, ignoreUnreadableDirectories: bool, ignoreVCSFiles: bool]
Finder = ref object case driver: FinderDriverType of LOCAL: local: LocalFinder of SSH: ssh: SSHFinder of FTP: ftp: AsyncFtpClient searchType: SearchType criteria: Criterias filters: Filters results: Results ## An instance of `Results`
FinderDriverType {.pure.} = enum LOCAL, SSH, FTP
LocalFinder = ref object of AbstractDriver
Results = ref object sortType: SortType case searchType: SearchType of SearchInFiles: fileResults: OrderedTableRef[string, FileFinder] of SearchInDirectories: dirResults: OrderedTableRef[string, Directory]
SearchType = enum SearchInFiles, SearchInDirectories
SortType = enum SortByModifiedTime, SortByChangedTime, SortByAccessedTime, SortByType, SortByName
SSHFinder = ref object of AbstractDriver sock: AsyncFD session: Session host: string port: Port username: string case authType: AuthType of authPassword: password: string of authPublicKeyFile: pubKeyFile, privateKeyFile, passphrase: string
Submodule = object name*: string
Procs
proc `!=`[S: FSize](fs: S): S
proc `<=`[S: FSize](fs: S): S
proc `<`[S: FSize](fs: S): S
proc `==`[S: FSize](fs: S): S
proc `>=`(fs: FSize): FSize {....raises: [], tags: [].}
proc `>`[S: FSize](fs: S): S
proc bytes(i: float): FSize {....raises: [], tags: [].}
proc exclude[F: Finder](finder: F; pattern: string): F
- Excludes files or directories by name or pattern
proc finder(path = "."; driver = LOCAL; searchType = SearchInFiles; isRecursive = false): Finder {....raises: [], tags: [].}
proc gb(i: float): FSize {....raises: [], tags: [].}
proc GB(i: float): FSize {....raises: [], tags: [].}
proc gb(i: int): FSize {....raises: [], tags: [].}
proc get(finder: Finder): Results {....raises: [OSError, ValueError], tags: [ReadDirEffect].}
- Execute Finder query and return the results
proc getCreationTime(file: FileFinder): Time {....raises: [], tags: [].}
- Returns the creation time
proc getFileSize(file: FileFinder): BiggestInt {....raises: [], tags: [].}
- Returns the file size of file (in bytes)
proc getInfo(file: FileFinder): FileInfo {....raises: [], tags: [].}
- Returns an instance of FileInfo https://nim-lang.org/docs/os.html#FileInfo
proc getLastAccessTime(file: FileFinder): Time {....raises: [], tags: [].}
- Returns the file's last read or write access time
proc getLastModificationTime(file: FileFinder): Time {....raises: [], tags: [].}
- Returns the file's last read or write access time
proc getName(file: FileFinder): string {....raises: [], tags: [].}
proc getPath(file: FileFinder): string {....raises: [], tags: [].}
- Returns path on disk for given FileFinder
proc getSize(file: FileFinder): string {....raises: [], tags: [].}
- Returns the current file size of given FileFinder auto-converted to Bytes, KB, MB, GB, or TB.
proc getSize(file: FileFinder; hideSizeLabel: bool): float {....raises: [], tags: [].}
- Returns the current file size of given FileFinder as float value, auto-converted to Bytes, KB, MB, GB or TB, without a label
proc gigabytes(i: float): FSize {....raises: [], tags: [].}
- FSize of i gigabytes
proc ignoreUnreadableDirs[F: Finder](finder: F): F
- Tells Finder to ignore unreadable directories.
proc ignoreVCS[F: Finder](finder: F; toIgnore: bool): F
- Tell finder to ignore Version Control Systems, such as Git and Mercurial. Those files are ignored by default when looking for files and directories, but you can change this behaviour by using this proc.
proc initSubmodule(): Submodule {....raises: [], tags: [].}
- Initialises a new Submodule object.
proc kb(i: float): FSize {....raises: [], tags: [].}
proc KB(i: float): FSize {....raises: [], tags: [].}
proc kb(i: int): FSize {....raises: [], tags: [].}
proc kilobytes(i: float): FSize {....raises: [], tags: [].}
- FSize of i kilobytes
proc lastTimeModified[F: Finder](finder: F; since: string): F
- Search for files or directories by last modified dates.
proc lastTimeModified[F: Finder](finder: F; startFrom, endTo: string): F
- Search for files or directories by last modified dates.
proc len(res: Results): int {....raises: [], tags: [].}
- Return the number of items in current Results.
proc mb(i: float): FSize {....raises: [], tags: [].}
proc MB(i: float): FSize {....raises: [], tags: [].}
proc mb(i: int): FSize {....raises: [], tags: [].}
proc megabytes(i: float): FSize {....raises: [], tags: [].}
- FSize of i megabytes
proc name(finder: Finder; pattern: string): Finder {....raises: [], tags: [].}
- Add one file name for searching
proc sortByAccessedTime[R: Results](res: R; order: algorithm.SortOrder = Descending): R
- Sorts files and directories by the last accessed time This is the time that the file was last accessed, read or written to
proc sortByCreationTime[R: Results](res: R; order: algorithm.SortOrder = Descending): R
- Sorts files and directories by creation time
proc sortByModifiedTime[R: Results](res: R; order: algorithm.SortOrder = Descending): R
- Sorts files and directories by the last modified time
proc sortByName[R: Results](res: R; order: algorithm.SortOrder = Ascending): R
- Sorts files and directories by name
proc sortBySize[R: Results](res: R; order: algorithm.SortOrder = Descending): R
- Sorts files and directories by size
proc sortByType[R: Results](res: R): R
- Sorts files and directories by type (directories before files), then by name
proc tb(i: float): FSize {....raises: [], tags: [].}
proc TB(i: float): FSize {....raises: [], tags: [].}
proc tb(i: int): FSize {....raises: [], tags: [].}
proc terabytes(i: float): FSize {....raises: [], tags: [].}
- FSize of i terabytes
Iterators
iterator files(res: Results): FileFinder {....raises: [], tags: [].}