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

Dealing with reserved file names under MS Windows #2961

Closed
lefou opened this issue Jan 10, 2024 · 1 comment · Fixed by #2964
Closed

Dealing with reserved file names under MS Windows #2961

lefou opened this issue Jan 10, 2024 · 1 comment · Fixed by #2964
Milestone

Comments

@lefou
Copy link
Member

lefou commented Jan 10, 2024

In PR #2959 I run into a hard diagnose issue with file names on MS Windows.

Here is a excerpt from an official Win32 documentation:

  • Do not use the following reserved names for the name of a file:

CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM¹, COM², COM³, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, LPT¹, LPT², and LPT³. Also avoid these names followed immediately by an extension; for example, NUL.txt and NUL.tar.gz are both equivalent to NUL. For more information, see Namespaces.

I think we should discuss a nice way to deal with it in Mill. Mill currently assumes all legal class names are supported. But having a target named con can fail on Windows with a uninformative error message. Since we create metadata files unter out/ like con.json, con.log and con.dest, which would all be illegal under a Windows file system namespace.

@lefou
Copy link
Member Author

lefou commented Jan 10, 2024

A rather simple and generic way could be to append a single character to all or only those reserved names. For example an underscore (_). Or the more Windows typical tilde (~). Resulting in names like con~.json, con~.json and con~.dest.

lefou added a commit that referenced this issue Jan 22, 2024
In case a segment path matches one of the reserved name of the Windows
filesystem namespace, we insert a `~` directly after the offending
segment part.

Here is a excerpt from an official [Win32
documentation](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#naming-conventions):

> * Do not use the following reserved names for the name of a file:
>
> CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7,
COM8, COM9, COM¹, COM², COM³, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6,
LPT7, LPT8, LPT9, LPT¹, LPT², and LPT³. Also avoid these names followed
immediately by an extension; for example, NUL.txt and NUL.tar.gz are
both equivalent to NUL. For more information, see
[Namespaces](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#win32-file-namespaces).

We do the insertions on all platforms, not only Windows, for consistency
of the `out/` folder.

Fix #2961

Pull request: #2964
@lefou lefou added this to the 0.11.7 milestone Jan 22, 2024
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 a pull request may close this issue.

1 participant