- a path is not a unique identifier of a file system object. They don’t have canonical names.
- don’t make any assumptions about case sensitivity, what file names are valid, or what the longest possible path is.
- avoid baking paths from strings as as much as possible. Use constructs like PathBuf (Rust) that prevent footguns like duplicated or incorrect dir separators. Never use a literal path separator char ‘/‘ or ‘\’ in code is a good rule of thumb.
In my experience, a program written in modern .NET 5+ and tested on Windows has a high probability to run flawlessly on Linux, without even a recompilation.
I can rely on Windows to still be running nice and happy a year later with no attention paid.
I can rely on Linux to die to a stiff breeze.
(Note: I'm probably cursed.)
It is the direct opposite of 36 years of extensive professional experience.
Linux is pretty tough. It will run on anything, and can cope with a lot of changes and damage.
21st century Windows is the most fragile OS I've worked with since classic MacOS.
I guess Go hooks into too high level of an API. But you can prefix all your paths with "\\?\" to "force it" to be evaluated as is.
Consider the following program:
package main
import "os"
func main() {
os.Mkdir(os.Args[1], 0777)
}
Invoking test.exe c:\test... will create c:\test
Invoking test.exe \\?\c:\test... will create c:\test...See: https://learn.microsoft.com/en-ca/windows/win32/fileio/namin...
The link also explains why the file path length limit and details how to disable the limit.
Easily changed in the registry/ with group policy, though 256 should not be the default today.
For example the built in .zip file support can’t extract long paths (7-zip however has no issue).
Also my Git client of choice (TortoiseGit) doesn’t fully handle long paths.
But day to day long paths on Windows is fortunately not really an issue any more and they’ve been steadily improving support over the years.
Despite generally being a fan of Windows, before Windows 10 the long path situation was infuriating, they even had a blog post acknowledging it’s a problem, but also stating it was going to be very non trivial to fix and as such they didn’t have any particular plans to fix it.
I suspect that WSL made the limitation more regularly painful enough that they could convince managers that it’s something that had to get fixed.
Windows Terminal was probably also motivated by WSL.
NTFS has always supported 32k characters in the path with each part being no more than 255 characters.
Office, OTOH, does not respect/observe MAX_PATH. Do not exceed ~240 characters in the path + filename for an Office document as Office will be unable to open it.
* It seems you decide whether to execute a file by its extension, e.g. `.php`
* You are complaining that Windows is stripping away spaces, so `.php ` becomes `.php`
* And supposedly this could lead the file being served as static text if you didn't have a Windows workaround?
It rather seems to me that POSIX accepting `.php ` as a filename, and this not being picked up by a `.php` check is problematic here.
If that test fails we could serve PHP source code instead of having it be evaluated, a potential security flaw.
Seriously, in Caddy, I have some of the most bizarre special code paths for Windows. For example: https://github.com/caddyserver/caddy/blob/c6eb186064091c79f4...
Can someone who understands and appreciates the way Windows does files please help me appreciate it too?
This article did not help me have gratitude for Windows: https://www.fileside.app/blog/2023-03-17_windows-file-paths/
> we realise that we can construct an almost unlimited number of different path strings that all refer to the same directory.
:o