gftp/list/file
File type returned by the list functions, representing a file or directory in the FTP server’s file system.
Types
Describes a file entry on the remote system. This data type is returned in a collection after parsing a LIST output
Each file comes with metadata such as name, type (file, directory, symlink), size, modification time, POSIX permissions and owner/group ids (if available).
Parsing
You can parse a LIST, MLSD, or MLST line by using the gftp/list module by calling any of the following functions:
parse_list- tries to parse the line as either POSIX or DOS format, returning an error if both failparse_mlsd- parses the line as MLSD format, which is a standardized format for machine-readable directory listings (RFC 3659)parse_mlst- parses the line as MLST format, which is a standardized format for machine-readable file listings (RFC 3659)
In case you opt for parse_list, the parser will first try to parse the line
as POSIX format and if it fails, it will try to parse it as DOS format.
pub opaque type File
Values
pub fn empty() -> File
Create a new empty File with the given name and default values for other fields.
pub fn file_type(file: File) -> file_type.FileType
Get the type of the file or directory.
pub fn gid(file: File) -> option.Option(Int)
Get the group ID (GID) of the file owner, if available. This is typically a POSIX-specific attribute and may not be present in all FTP server implementations.
pub fn modified(file: File) -> option.Option(timestamp.Timestamp)
Get the last modification time of the file or directory as a Timestamp.
pub fn permissions(
file: File,
) -> option.Option(permission.FilePermissions)
Get the POSIX permissions of the file or directory, if available. This is typically a POSIX-specific attribute and may not be present in all FTP server implementations
pub fn size(file: File) -> Int
Get the size of the file in bytes. For directories, this may be implementation-defined and not necessarily meaningful.
pub fn symlink_target(file: File) -> option.Option(String)
If the file is a symbolic link, get the target path of the link. Otherwise, return None.
pub fn uid(file: File) -> option.Option(Int)
Get the user ID (UID) of the file owner, if available. This is typically a POSIX-specific attribute and may not be present in all FTP server implementations.
pub fn with_file_type(
file: File,
file_type: file_type.FileType,
) -> File
Set the type of the file (file, directory, or symlink) and return a new File with the updated type.
pub fn with_gid(file: File, gid: Int) -> File
Set the GID of the file, if available. This is typically a POSIX-specific operation and may not be supported by all FTP servers.
pub fn with_modified(
file: File,
modified: timestamp.Timestamp,
) -> File
Set the last modification time of the file or directory, if available. This is typically a POSIX-specific operation and may not be supported by all FTP servers.
pub fn with_name(file: File, name: String) -> File
Set the name of the file or directory and return a new File with the updated name.
pub fn with_permissions(
file: File,
permissions: permission.FilePermissions,
) -> File
Set the POSIX permissions of the file or directory, if available. This is typically a POSIX-specific operation and may not be supported by all FTP servers.