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

Add File#rename #13640

Merged
merged 1 commit into from Jul 22, 2023
Merged

Conversation

carlhoerberg
Copy link
Contributor

Like File.rename, but updates the @path of the instance

Like File.rename, but updates the `@path` of the instance
Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable 👍

@straight-shoota straight-shoota added this to the 1.10.0 milestone Jul 7, 2023
@straight-shoota straight-shoota changed the title File#rename Add File#rename Jul 22, 2023
@straight-shoota straight-shoota merged commit 56e32f6 into crystal-lang:master Jul 22, 2023
52 checks passed
# Rename the current `File`
def rename(new_filename : Path | String) : Nil
File.rename(@path, new_filename)
@path = new_filename.to_s
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the both cases the same?
new_filename could be just a file name (as the test covers)) but could be a (full) path...
BTW is @path a (stringified) path or a file name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@path is whatever you pass to the constructor. It can be a single file name or consist of multiple path components. It makes no difference which.

Blacksmoke16 pushed a commit to Blacksmoke16/crystal that referenced this pull request Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants