DirEntry
Represent individual entries within a directory. The
entries() function and the
Path.entries() method return iterators over this type.
Fields
name
Returns the final path component for the entry.
type
Returns the file type as a Sym.
Possible values when present:
| Value | Description |
|---|---|
:FILE: |
Regular file |
:DIR: |
Directory |
:SYMLINK: |
Symbolic link |
:FIFO: |
Named pipe (FIFO) |
:CHAR_DEVICE: |
Character device |
:BLOCK_DEVICE: |
Block device |
:SOCKET: |
Unix domain socket |
:UNKNOWN: |
Type could not be determined |
for entry = entries .
if entry.type == :DIR:
echo "Directory: $(entry.name)"
else if entry.type == :FILE:
echo "File: $(entry.name)"
else if entry.type == :UNKNOWN:
echo "Unknown type: $(entry.name)"
Platform-Specific Fields
Unix-Only Fields
The following fields are only available on Unix systems:
ino
The inode number of the file system entry.
Usage Examples
Basic Iteration
Collecting to Array
# Get all entries as an array
let all_entries = [...entries "."]
echo "Found $(all_entries.len) entries"
Working with Paths
let dir = Path ./src
for entry = dir.entries()
let full_path = (dir / entry)
echo "Path: $full_path"
if full_path.exists()
echo " Confirmed: exists"
Operators
/
path / entry returns the derived Path for that directory entry.