Skip to content

Filesystem API needs more documenation #29300

New issue

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

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

Already on GitHub? # to your account

Closed
Diggsey opened this issue Oct 25, 2015 · 7 comments
Closed

Filesystem API needs more documenation #29300

Diggsey opened this issue Oct 25, 2015 · 7 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. P-medium Medium priority

Comments

@Diggsey
Copy link
Contributor

Diggsey commented Oct 25, 2015

A lot of the filesystem API is not explicit about its behaviour. This includes:

  • Will operations silently overwrite files/directories, or fail instead?
  • Platform-specific semantics
  • Which underlying OS APIs are used
  • What the result of a failed operation might be (for example, deleting a directory might fail with some files being deleted and others not)

Without this documentation it makes it very difficult to write robust tools which access the filesystem, especially if they have to be cross-platform. There also seem to be several places where the library could attempt to be more consistent across platforms.

A simple example is what happens in the case of symlinks. On linux, you delete a directory symlink the same way you delete a file, whereas on windows you should delete it the same way you'd delete a directory. It would be useful if there was a safe way to delete a directory symlink that is both cross-platform, and is guaranteed not to delete the contents of the directory.

Another example is renaming: can you rename a directory onto another? It doesn't seem so, but you can't just delete the destination first, in case the source == the destination, in which case you'll delete the wrong files! But at the same time, there's no way to test paths for equality reliably.

edit:
Another example: how relative paths are treated when creating a symlink. Is a relative path resolved before creating the symlink, or afterwards? Is that true on all platforms?

@retep998
Copy link
Member

There is a relatively simple technique to determine whether two files are identical. I could write a PR adding such a method if it can be decided what such a function should be called and where to provide it.

@huonw huonw added the A-docs label Oct 26, 2015
@steveklabnik
Copy link
Member

Platform-specific semantics
Which underlying OS APIs are used

These are things which we don't necessarily want to document, as it commits us to a certain kind of stability.

In general, I agree with you, but this section of the API hasn't had any real specific docs work done on it yet, so yeah, it's gonna be a bit under-done at the moment. Anyone who wants to help with this, please let me know!

@retep998
Copy link
Member

Which underlying OS APIs are used

If Rust ever intends to support Windows store apps or universal apps then it'll need to be able to use app versions of many system APIs like CreateFile2 instead of CreateFile, so many of the OS APIs that are used will likely differ across targets on Windows. So any documentation should be careful to not describe it as a commitment or guarantee.

@steveklabnik
Copy link
Member

part of #29356

@steveklabnik
Copy link
Member

Triage: no change

@steveklabnik steveklabnik added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Mar 10, 2017
@steveklabnik steveklabnik added the P-medium Medium priority label May 24, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 24, 2017
@steveklabnik steveklabnik added the E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. label May 28, 2018
@steveklabnik
Copy link
Member

Triage: this is very similar to #24795 , but for std::fs rather than std::io. Its status is the same #24795 (comment)

@steveklabnik
Copy link
Member

Given that #24795 was closed, I'm also going to close this. There are some parts of this issue that are not identical to that issue, but a vague list from 2015 isn't useful. If there's anything that needs to be clarified in specific API docs, please open new, detailed issues. Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

5 participants