Packages

A Gleam FTP/FTPS client library with full RFC support for both passive and active mode

Current section

Files

Jump to
gftp src gftp@list@file.erl
Raw

src/gftp@list@file.erl

-module(gftp@list@file).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/gftp/list/file.gleam").
-export([name/1, file_type/1, size/1, modified/1, uid/1, gid/1, permissions/1, symlink_target/1, empty/0, with_name/2, with_file_type/2, with_size/2, with_modified/2, with_permissions/2, with_uid/2, with_gid/2]).
-export_type([file/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(" File type returned by the `list` functions, representing a file or directory in the FTP server's file system.\n").
-opaque file() :: {file,
binary(),
gftp@list@file_type:file_type(),
integer(),
gleam@option:option(gleam@time@timestamp:timestamp()),
gleam@option:option(integer()),
gleam@option:option(integer()),
gleam@option:option(gftp@list@permission:file_permissions())}.
-file("src/gftp/list/file.gleam", 37).
?DOC(" Get the name of the file or directory.\n").
-spec name(file()) -> binary().
name(File) ->
erlang:element(2, File).
-file("src/gftp/list/file.gleam", 42).
?DOC(" Get the type of the file or directory.\n").
-spec file_type(file()) -> gftp@list@file_type:file_type().
file_type(File) ->
erlang:element(3, File).
-file("src/gftp/list/file.gleam", 47).
?DOC(" Get the size of the file in bytes. For directories, this may be implementation-defined and not necessarily meaningful.\n").
-spec size(file()) -> integer().
size(File) ->
erlang:element(4, File).
-file("src/gftp/list/file.gleam", 52).
?DOC(" Get the last modification time of the file or directory as a `Timestamp`.\n").
-spec modified(file()) -> gleam@option:option(gleam@time@timestamp:timestamp()).
modified(File) ->
erlang:element(5, File).
-file("src/gftp/list/file.gleam", 58).
?DOC(
" Get the user ID (UID) of the file owner, if available. \n"
" This is typically a POSIX-specific attribute and may not be present in all FTP server implementations.\n"
).
-spec uid(file()) -> gleam@option:option(integer()).
uid(File) ->
erlang:element(6, File).
-file("src/gftp/list/file.gleam", 64).
?DOC(
" Get the group ID (GID) of the file owner, if available. \n"
" This is typically a POSIX-specific attribute and may not be present in all FTP server implementations.\n"
).
-spec gid(file()) -> gleam@option:option(integer()).
gid(File) ->
erlang:element(7, File).
-file("src/gftp/list/file.gleam", 70).
?DOC(
" Get the POSIX permissions of the file or directory, if available.\n"
" This is typically a POSIX-specific attribute and may not be present in all FTP server implementations\n"
).
-spec permissions(file()) -> gleam@option:option(gftp@list@permission:file_permissions()).
permissions(File) ->
erlang:element(8, File).
-file("src/gftp/list/file.gleam", 75).
?DOC(" If the file is a symbolic link, get the target path of the link. Otherwise, return `None`.\n").
-spec symlink_target(file()) -> gleam@option:option(binary()).
symlink_target(File) ->
case erlang:element(3, File) of
{symlink, Target} ->
{some, Target};
_ ->
none
end.
-file("src/gftp/list/file.gleam", 83).
?DOC(" Create a new empty `File` with the given name and default values for other fields.\n").
-spec empty() -> file().
empty() ->
{file, <<""/utf8>>, file, 0, none, none, none, none}.
-file("src/gftp/list/file.gleam", 88).
?DOC(" Set the name of the file or directory and return a new `File` with the updated name.\n").
-spec with_name(file(), binary()) -> file().
with_name(File, Name) ->
{file,
Name,
erlang:element(3, File),
erlang:element(4, File),
erlang:element(5, File),
erlang:element(6, File),
erlang:element(7, File),
erlang:element(8, File)}.
-file("src/gftp/list/file.gleam", 93).
?DOC(" Set the type of the file (file, directory, or symlink) and return a new `File` with the updated type.\n").
-spec with_file_type(file(), gftp@list@file_type:file_type()) -> file().
with_file_type(File, File_type) ->
{file,
erlang:element(2, File),
File_type,
erlang:element(4, File),
erlang:element(5, File),
erlang:element(6, File),
erlang:element(7, File),
erlang:element(8, File)}.
-file("src/gftp/list/file.gleam", 98).
?DOC(" Set the size of the file in bytes and return a new `File` with the updated size.\n").
-spec with_size(file(), integer()) -> file().
with_size(File, Size) ->
{file,
erlang:element(2, File),
erlang:element(3, File),
Size,
erlang:element(5, File),
erlang:element(6, File),
erlang:element(7, File),
erlang:element(8, File)}.
-file("src/gftp/list/file.gleam", 103).
?DOC(" 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.\n").
-spec with_modified(file(), gleam@time@timestamp:timestamp()) -> file().
with_modified(File, Modified) ->
{file,
erlang:element(2, File),
erlang:element(3, File),
erlang:element(4, File),
{some, Modified},
erlang:element(6, File),
erlang:element(7, File),
erlang:element(8, File)}.
-file("src/gftp/list/file.gleam", 108).
?DOC(" 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.\n").
-spec with_permissions(file(), gftp@list@permission:file_permissions()) -> file().
with_permissions(File, Permissions) ->
{file,
erlang:element(2, File),
erlang:element(3, File),
erlang:element(4, File),
erlang:element(5, File),
erlang:element(6, File),
erlang:element(7, File),
{some, Permissions}}.
-file("src/gftp/list/file.gleam", 113).
?DOC(" Set the UID of the file, if available. This is typically a POSIX-specific operation and may not be supported by all FTP servers.\n").
-spec with_uid(file(), integer()) -> file().
with_uid(File, Uid) ->
{file,
erlang:element(2, File),
erlang:element(3, File),
erlang:element(4, File),
erlang:element(5, File),
{some, Uid},
erlang:element(7, File),
erlang:element(8, File)}.
-file("src/gftp/list/file.gleam", 118).
?DOC(" Set the GID of the file, if available. This is typically a POSIX-specific operation and may not be supported by all FTP servers.\n").
-spec with_gid(file(), integer()) -> file().
with_gid(File, Gid) ->
{file,
erlang:element(2, File),
erlang:element(3, File),
erlang:element(4, File),
erlang:element(5, File),
erlang:element(6, File),
{some, Gid},
erlang:element(8, File)}.