-module(sqlode@internal@sql_paths). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/sqlode/internal/sql_paths.gleam"). -export([expand/2]). -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/sqlode/internal/sql_paths.gleam", 21). ?DOC(false). -spec expand(list(binary()), fun((binary(), binary()) -> QYY)) -> {ok, list(binary())} | {error, QYY}. expand(Paths, Error_fn) -> _pipe = Paths, _pipe@3 = gleam@list:try_map( _pipe, fun(Path) -> case simplifile_erl:is_directory(Path) of {ok, true} -> case simplifile:get_files(Path) of {ok, Files} -> Sql_files = begin _pipe@1 = Files, _pipe@2 = gleam@list:filter( _pipe@1, fun(F) -> gleam_stdlib:string_ends_with( F, <<".sql"/utf8>> ) end ), gleam@list:sort( _pipe@2, fun gleam@string:compare/2 ) end, case Sql_files of [] -> {error, Error_fn( Path, <<"Directory contains no .sql files"/utf8>> )}; _ -> {ok, Sql_files} end; {error, Error} -> {error, Error_fn( Path, <<"Failed to read directory: "/utf8, (simplifile:describe_error(Error))/binary>> )} end; {ok, false} -> {ok, [Path]}; {error, Error@1} -> {error, Error_fn( Path, <<"Failed to access path: "/utf8, (simplifile:describe_error(Error@1))/binary>> )} end end ), gleam@result:map(_pipe@3, fun lists:append/1).