-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
FileUtils: Add a recursive chmod_r
and chown_r
#5230
Conversation
986d11c
to
9074799
Compare
chmod_r
and chown_r
chmod_r
and chown_r
9074799
to
d026b4d
Compare
I'm not sure if these dedicated methods make sense... it's just quite easy to get this done with the non-recursive variants. Dir["path/**"] { |path| File.chmod(path, mode) } |
spec/std/file_utils_spec.cr
Outdated
|
||
describe "chown_r" do | ||
it "change the owner of the directory recursively" do | ||
data_path = File.join(__DIR__, "data") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't plan on actually running the method, there is no point in setting up the directories.
d026b4d
to
d08db37
Compare
@straight-shoota I'm thinking now if it stiil makes sense to have |
d08db37
to
5db441c
Compare
I realise there is already a precedence for using different method names for different modes in So instead of: def chmod_r(path, mode : Int)
...
end We'd have: def chmod(path, mode : Int, recurse : Bool = false)
...
end I'd also prefer methods to be named for the conceptual action they take, rather than named after the historic way to take this action in an operating system's shell, and to use words rather than abbreviations or acronyms. So instead of More generally, the use of I feel the method name should equal the action taken, it should not equal the action taken + options applied to the action. |
@j8r Yes, the root folder must be handled separtely, but I'd still prefer that over an additional method. Maybe it would make sense to have something like |
I agree with you @lachlan for the In an other hand I disagree to replace all LibC references by new names, specially For Dir.create("dir/", recurse: true)
Dir.delete("dir/")
I very like the |
Please let's not discuss these advanced ideas in this PR, open a new issue for that. |
Sorry, I open an issue |
Issue opened at #5231 |
I close this PR. |
Implements a recursive
chown
andchmod
that applies to all subfiles and subdirectories at a given path.