Packages
gleam_erlang
0.17.1
1.3.0
1.2.0
1.1.0
1.0.0
1.0.0-rc1
0.34.0
0.33.0
0.32.0
0.31.0
0.30.0
0.29.0
0.28.0
0.27.0
0.26.0
0.25.0
0.24.0
0.23.1
0.23.0
0.22.0
0.21.0
0.20.0
0.19.0
0.18.1
0.18.0
0.18.0-rc1
retired
0.17.1
0.17.0
0.16.0
0.15.0
0.14.0
0.13.0
0.12.0
0.11.0
0.10.0
0.9.3
0.9.2
0.9.1
0.9.0
0.8.0
0.7.0
0.6.0
0.5.0
0.4.0
0.3.0
0.2.0
0.1.0
Types and functions for programs running on Erlang!
Current section
Files
Jump to
Current section
Files
src/gleam@erlang@file.erl
-module(gleam@erlang@file).
-compile(no_auto_import).
-export([is_directory/1, is_file/1, make_directory/1, list_directory/1, delete_directory/1, recursive_delete/1, read/1, read_bits/1, write/2, write_bits/2, append/2, append_bits/2, delete/1]).
-export_type([reason/0]).
-type reason() :: eacces |
eagain |
ebadf |
ebadmsg |
ebusy |
edeadlk |
edeadlock |
edquot |
eexist |
efault |
efbig |
eftype |
eintr |
einval |
eio |
eisdir |
eloop |
emfile |
emlink |
emultihop |
enametoolong |
enfile |
enobufs |
enodev |
enolck |
enolink |
enoent |
enomem |
enospc |
enosr |
enostr |
enosys |
enotblk |
enotdir |
enotsup |
enxio |
eopnotsupp |
eoverflow |
eperm |
epipe |
erange |
erofs |
espipe |
esrch |
estale |
etxtbsy |
exdev |
not_utf8.
-spec is_directory(binary()) -> boolean().
is_directory(Field@0) ->
filelib:is_dir(Field@0).
-spec is_file(binary()) -> boolean().
is_file(Field@0) ->
filelib:is_file(Field@0).
-spec make_directory(binary()) -> {ok, nil} | {error, reason()}.
make_directory(Field@0) ->
gleam_erlang_ffi:make_directory(Field@0).
-spec list_directory(binary()) -> {ok, list(binary())} | {error, reason()}.
list_directory(Field@0) ->
gleam_erlang_ffi:list_directory(Field@0).
-spec delete_directory(binary()) -> {ok, nil} | {error, reason()}.
delete_directory(Field@0) ->
gleam_erlang_ffi:delete_directory(Field@0).
-spec recursive_delete(binary()) -> {ok, nil} | {error, reason()}.
recursive_delete(Field@0) ->
gleam_erlang_ffi:recursive_delete(Field@0).
-spec read(binary()) -> {ok, binary()} | {error, reason()}.
read(Path) ->
_pipe = Path,
_pipe@1 = gleam_erlang_ffi:read_file(_pipe),
gleam@result:then(
_pipe@1,
fun(Content) -> case gleam@bit_string:to_string(Content) of
{ok, String} ->
{ok, String};
{error, nil} ->
{error, not_utf8}
end end
).
-spec read_bits(binary()) -> {ok, bitstring()} | {error, reason()}.
read_bits(Path) ->
gleam_erlang_ffi:read_file(Path).
-spec write(binary(), binary()) -> {ok, nil} | {error, reason()}.
write(Contents, Path) ->
_pipe = Contents,
_pipe@1 = gleam@bit_string:from_string(_pipe),
gleam_erlang_ffi:write_file(_pipe@1, Path).
-spec write_bits(bitstring(), binary()) -> {ok, nil} | {error, reason()}.
write_bits(Contents, Path) ->
gleam_erlang_ffi:write_file(Contents, Path).
-spec append(binary(), binary()) -> {ok, nil} | {error, reason()}.
append(Contents, Path) ->
_pipe = Contents,
_pipe@1 = gleam@bit_string:from_string(_pipe),
gleam_erlang_ffi:append_file(_pipe@1, Path).
-spec append_bits(bitstring(), binary()) -> {ok, nil} | {error, reason()}.
append_bits(Contents, Path) ->
gleam_erlang_ffi:append_file(Contents, Path).
-spec delete(binary()) -> {ok, nil} | {error, reason()}.
delete(Field@0) ->
gleam_erlang_ffi:delete_file(Field@0).