bcpeinhardt / simplifile

Simple file operations for Gleam that work on all targets (Erlang/Node/Deno)
71 stars 10 forks source link

`copy` function #11

Closed aslilac closed 11 months ago

aslilac commented 11 months ago

something like fn(String, to: String) -> Result(Nil, _)

it'd be great if it could make sure the directory containing to exists as well

bcpeinhardt commented 11 months ago

This issue is related to #12

What's the mechanism by which you want this to occur? I mean should this function execute the cp command, or read the contents of the file to a buffer and write it to the new file, or maybe something fancy with streams? Asking just because I truly want to know what would be more useful.

aslilac commented 11 months ago

does erlang not provide a copy function? I know node and deno both do, which just maps to a syscall

I'd just expect it to map to whatever file-copy implementation the platform provides

bcpeinhardt commented 11 months ago

It does lol, just wanted to make sure that's what you wanted :) I should have these published sometime today it seems extremely straightforward.

aslilac commented 11 months ago

thx bestie :3

bcpeinhardt commented 11 months ago

Pssst this is published now as copy_file. For making sure the directory exists I would use is_directory or create_directory_all depending on how you want to handle it.