Current section

44 Versions

Jump to

Compare versions

7 files changed
+183 additions
-83 deletions
  @@ -1,5 +1,5 @@
1 1 name = "simplifile"
2 - version = "1.1.0"
2 + version = "1.1.1"
3 3 description = "Basic file operations that work on all targets"
4 4
5 5 licences = ["Apache-2.0"]
  @@ -1,6 +1,6 @@
1 1 {<<"name">>, <<"simplifile">>}.
2 2 {<<"app">>, <<"simplifile">>}.
3 - {<<"version">>, <<"1.1.0">>}.
3 + {<<"version">>, <<"1.1.1">>}.
4 4 {<<"description">>, <<"Basic file operations that work on all targets">>}.
5 5 {<<"licenses">>, [<<"Apache-2.0">>]}.
6 6 {<<"build_tools">>, [<<"gleam">>]}.
  @@ -1,5 +1,5 @@
1 1 {application, simplifile, [
2 - {vsn, "1.1.0"},
2 + {vsn, "1.1.1"},
3 3 {applications, [gleam_stdlib,
4 4 gleeunit]},
5 5 {description, "Basic file operations that work on all targets"},
  @@ -269,7 +269,17 @@ get_files(Directory) ->
269 269 Paths = gleam@list:map(
270 270 Contents,
271 271 fun(Segment) ->
272 - <<<<Directory/binary, "/"/utf8>>/binary, Segment/binary>>
272 + case begin
273 + _pipe = Directory,
274 + gleam@string:ends_with(_pipe, <<"/"/utf8>>)
275 + end of
276 + true ->
277 + <<Directory/binary, Segment/binary>>;
278 +
279 + false ->
280 + <<<<Directory/binary, "/"/utf8>>/binary,
281 + Segment/binary>>
282 + end
273 283 end
274 284 ),
275 285 Files = gleam@list:filter(Paths, fun is_file/1),
  @@ -361,7 +361,16 @@ pub fn rename_directory(
361 361 ///
362 362 pub fn get_files(in directory: String) -> Result(List(String), FileError) {
363 363 use contents <- result.try(read_directory(directory))
364 - let paths = list.map(contents, fn(segment) { directory <> "/" <> segment })
364 + let paths =
365 + list.map(contents, fn(segment) {
366 + case
367 + directory
368 + |> string.ends_with("/")
369 + {
370 + True -> directory <> segment
371 + False -> directory <> "/" <> segment
372 + }
373 + })
365 374 let files = list.filter(paths, is_file)
366 375 case list.filter(paths, is_directory) {
367 376 [] -> Ok(files)
Loading more files…