Current section
Files
Jump to
Current section
Files
src/sketch_css@path.erl
-module(sketch_css@path).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([dirname/1, join/2]).
-file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/path.gleam", 15).
-spec dirname(binary()) -> {ok, binary()} | {error, snag:snag()}.
dirname(Path) ->
gleam@result:map(
begin
_pipe = simplifile_erl:is_file(Path),
_pipe@1 = snag:map_error(_pipe, fun gleam@string:inspect/1),
snag:context(_pipe@1, <<"Impossible to detect file"/utf8>>)
end,
fun(Is_file) ->
gleam@bool:guard(not Is_file, Path, fun() -> _pipe@2 = Path,
_pipe@3 = gleam@string:split(_pipe@2, <<"/"/utf8>>),
_pipe@4 = lists:reverse(_pipe@3),
_pipe@5 = gleam@list:drop(_pipe@4, 1),
_pipe@6 = lists:reverse(_pipe@5),
gleam@string:join(_pipe@6, <<"/"/utf8>>) end)
end
).
-file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/path.gleam", 31).
-spec join(binary(), binary()) -> binary().
join(Path, Segment) ->
_pipe = [Path, Segment],
_pipe@1 = gleam@string:join(_pipe, <<"/"/utf8>>),
gleam@string:replace(_pipe@1, <<"//"/utf8>>, <<"/"/utf8>>).