Skip to content

fs_fake: implement rename #2080

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jonludlam
Copy link
Contributor

No description provided.

@@ -81,6 +81,17 @@ class MlFakeDevice {
}
}

rename(oldname, newname) {
if (this.exists(newname))
caml_raise_sys_error(this.nm(newname) + " : file already exists");
Copy link
Member

Choose a reason for hiding this comment

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

This is not the expected behavior.
The doc says

If a file named
[newpath] already exists, its contents will be replaced with those of
[oldpath].

if (!this.exists(oldname))
caml_raise_sys_error(this.nm(oldname) + " : no such file or directory");
if (this.is_dir(oldname))
caml_raise_sys_error(this.nm(oldname) + " : not a file");
Copy link
Member

Choose a reason for hiding this comment

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

The doc says:

Rename a file or directory. [rename oldpath newpath] renames the
file or directory called [oldpath], giving it [newpath] as its new name,
moving it between (parent) directories if needed.

We shouldn't fail on directory.

You should probably add tests in compiler/tests-compiler/sys_fs.ml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants