5 ms·
It's very tricky to do cross platform file handling stuff, and only the most mature projects have ironed out this. Just look at your pet project and see if it h
by alkonaut 10y ago
It's very tricky to do cross platform file handling stuff, and only the most mature projects have ironed out this. Just look at your pet project and see if it handles
- Windows and unix line breaks in text files
- Windows and unix path separators
- BOM and non-BOM marked files if parsing UTF
- Forbidden filenames such as in this article
By "handling" I mean it should accept or fail nicely on unexpected input - e.g. say that line breaks should be unix style, or paths should be backslashes etc. Very few projects actually do this well. Even fewer will do even more complex things like handling too long paths with nice error messages etc.
- tannhaeuser 10y agoSince Windows 10 now comes with an official Linux subsystem, why not just use POSIX APIs and conventions everywhere, and not bother with Windows-specific code if possible?
- untog 10y agoFor one, because the Linux subsystem is an optional install. If you're making anything user-facing you can't rely on it being there - it's really a tool for developers, not end-users.
- alkonaut 10y agoDepends on what type of application you are making. For a library that can be used in a "real" graphical Windows application, you can't make a posix type shortcut. I think "if possible" is (at least still) very rarely the case that it is.
- int_19h 10y agoBecause this leaks to the user. For example, you'll be dealing with paths like /mnt/c/..., which, if you surface it in your UI, will rather confuse someone who expects C:\... And speaking of UI, that's one major hurdle right there.
- dbremner 10y agoHere is a character encoding issue that I ran into about a year ago. git does not support UTF-16LE[0]. The result is that UTF-16LE encoded files will be mangled[1] by the line ending conversion. There is at least one generated Visual Studio file (GlobalSuppressions.cs) that is saved in UTF-16 by default. [0] https://github.com/libgit2/libgit2/issues/1009 https://github.com/libgit2/libgit2/issues/1009 [1] https://github.com/Microsoft/Windows-classic-samples/issues/5 https://github.com/Microsoft/Windows-classic-samples/issues/...
- ensiferum 10y ago- illegal characters in file names such as !, |, ^
- bzbarsky 10y ago>- Windows and unix line breaks in text files And Mac classic linebreaks (\r only), for that matter.