Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request: File cp/mv/rm #1058

Closed
elia opened this issue Jul 29, 2015 · 14 comments
Closed

request: File cp/mv/rm #1058

elia opened this issue Jul 29, 2015 · 14 comments
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:feature status:implemented topic:stdlib

Comments

@elia
Copy link
Contributor

elia commented Jul 29, 2015

Those are on FileUtils in Ruby

I don't have any particular opinion about where they should go (File, Dir, FileSystem, FileUtils, …)

@asterite
Copy link
Member

If somebody wants to tackle this, we'll be more than happy to merge pull requests for this. Ideally File/FileUtils should be in Crystal.

@daviswahl
Copy link
Contributor

Accidentally deleted my comment -- I would be happy to take this on, but on second thought this is low level C stuff which I really shouldn't be getting involved in.

@refi64
Copy link
Contributor

refi64 commented Jul 30, 2015

I would love trying this! I have pretty much memorized half the Posix filesystem functions from using them in C++. :O

@elia
Copy link
Contributor Author

elia commented Jul 30, 2015

I would be happy to take this on, but on second thought this is low level C stuff which I really shouldn't be getting involved in.

Same here

@kirbyfan64 <3

@refi64
Copy link
Contributor

refi64 commented Aug 5, 2015

Are rm and mv really needed? Can't one already use File.delete and File.rename?

@ysbaddaden
Copy link
Contributor

They're nice in FileUtils since Rake includes it, so we can go shell-like in tasks. I'm not sure they're so interesting in Crystal.

@EvanHahn
Copy link
Contributor

I agree with @kirbyfan64 here:

Can't one already use File.delete and File.rename?

@ysbaddaden
Copy link
Contributor

That depends: if we want FileUtils.rm_r and FileUtils.rm_rf then not having FileUtils.rm might be weird. Same for mv since File.rename could feel odd:

include FileUtils

cp src, dst
File.rename dst, dst2
rm_rf dst2

That being said, these methods would be aliases, and maybe we don't want shell-induced naming, so we could prefer better method names in File and Dir, like Dir.delete(path, recursively: true) or Dir.copy(src, dst) and have a shard provide FileUtils instead.

@asterite
Copy link
Member

Yes, I'm still unsure about what's the best thing to do here: have separate methods in File, Dir, etc. Or have them all in FileUtils with unix-like names. Or have both.

Having both is really not a bad option, because if your code needs to do "bashy" stuff then it will look similar to bash, and if you need to rename a file here and there you can just use File.rename instead of FileUtils.mv. These are like aliases but probably don't bother much. Aliases are mostly a problem when all of them need to be in related types (like the case of length/size/count in String, Array, Hash, Deque and possibly other containers), because if I want to add a new container I have to remember to implement all these aliases.

@ysbaddaden
Copy link
Contributor

Sounds good to me.

@jhass jhass added the good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. label Jun 2, 2016
@sevk
Copy link

sevk commented Jul 28, 2016

can we auto convert from this file : https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb

@sdogruyol
Copy link
Member

@spalladino since #3420 is merged can we close this?

@spalladino
Copy link
Contributor

Certainly! Thanks for spotting this @sdogruyol :-)

@sdogruyol
Copy link
Member

@spalladino gracias 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:feature status:implemented topic:stdlib
Projects
None yet
Development

No branches or pull requests

10 participants