Current section
Files
Jump to
Current section
Files
src/sketch_css@fs.erl
-module(sketch_css@fs).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/sketch_css/fs.gleam").
-export([cwd/0, read_file/1, write_file/2, mkdir/2, is_directory/1, readdir/2, current_directory/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(false).
-file("src/sketch_css/fs.gleam", 8).
?DOC(false).
-spec cwd() -> {ok, binary()} | {error, snag:snag()}.
cwd() ->
_pipe = simplifile:current_directory(),
_pipe@1 = snag:map_error(_pipe, fun gleam@string:inspect/1),
snag:context(_pipe@1, <<"Impossible to get current directory"/utf8>>).
-file("src/sketch_css/fs.gleam", 32).
?DOC(false).
-spec read_file(binary()) -> {ok, binary()} | {error, snag:snag()}.
read_file(Path) ->
_pipe = simplifile:read(Path),
_pipe@1 = snag:map_error(_pipe, fun gleam@string:inspect/1),
_pipe@2 = snag:context(_pipe@1, <<"Impossible to read file"/utf8>>),
snag:context(_pipe@2, <<"file: "/utf8, Path/binary>>).
-file("src/sketch_css/fs.gleam", 39).
?DOC(false).
-spec write_file(binary(), binary()) -> {ok, nil} | {error, snag:snag()}.
write_file(Path, Content) ->
_pipe = simplifile:write(Path, Content),
_pipe@1 = snag:map_error(_pipe, fun gleam@string:inspect/1),
_pipe@2 = snag:context(_pipe@1, <<"Impossible to write file"/utf8>>),
snag:context(_pipe@2, <<"file: "/utf8, Path/binary>>).
-file("src/sketch_css/fs.gleam", 46).
?DOC(false).
-spec mkdir(binary(), boolean()) -> {ok, nil} | {error, snag:snag()}.
mkdir(Dir, Recursive) ->
_pipe = case Recursive of
true ->
simplifile:create_directory_all(Dir);
false ->
simplifile_erl:create_directory(Dir)
end,
_pipe@1 = snag:map_error(_pipe, fun gleam@string:inspect/1),
_pipe@2 = snag:context(_pipe@1, <<"Impossible to create directory"/utf8>>),
snag:context(_pipe@2, <<"dir: "/utf8, Dir/binary>>).
-file("src/sketch_css/fs.gleam", 56).
?DOC(false).
-spec read_directory(binary()) -> {ok, list(binary())} | {error, snag:snag()}.
read_directory(Dir) ->
_pipe = simplifile_erl:read_directory(Dir),
_pipe@1 = snag:map_error(_pipe, fun gleam@string:inspect/1),
_pipe@2 = snag:context(_pipe@1, <<"Impossible to read the directory"/utf8>>),
snag:context(_pipe@2, <<"dir: "/utf8, Dir/binary>>).
-file("src/sketch_css/fs.gleam", 63).
?DOC(false).
-spec is_directory(binary()) -> {ok, boolean()} | {error, snag:snag()}.
is_directory(Dir) ->
_pipe = simplifile_erl:is_directory(Dir),
_pipe@1 = snag:map_error(_pipe, fun gleam@string:inspect/1),
_pipe@2 = snag:context(_pipe@1, <<"Impossible to test the directory"/utf8>>),
snag:context(_pipe@2, <<"dir: "/utf8, Dir/binary>>).
-file("src/sketch_css/fs.gleam", 16).
?DOC(false).
-spec readdir(binary(), boolean()) -> {ok, list(binary())} |
{error, snag:snag()}.
readdir(Dir, Recursive) ->
gleam@result:map(
read_directory(Dir),
fun(Content) ->
Dir@1 = <<Dir/binary, "/"/utf8>>,
Content@1 = gleam@list:map(
Content,
fun(_capture) -> gleam@string:append(Dir@1, _capture) end
),
gleam@bool:guard(
not Recursive,
Content@1,
fun() ->
gleam@list:flatten(
begin
gleam@list:filter_map(
Content@1,
fun(Path) ->
gleam@result:'try'(
is_directory(Path),
fun(Is_dir) ->
gleam@bool:guard(
Is_dir,
readdir(Path, Recursive),
fun() -> {ok, [Path]} end
)
end
)
end
)
end
)
end
)
end
).
-file("src/sketch_css/fs.gleam", 70).
?DOC(false).
-spec current_directory() -> {ok, binary()} | {error, snag:snag()}.
current_directory() ->
_pipe = simplifile:current_directory(),
_pipe@1 = snag:map_error(_pipe, fun gleam@string:inspect/1),
snag:context(_pipe@1, <<"Impossible to read current directory"/utf8>>).