6 ms·
Maybe Microsoft could give apps a way to opt out of this legacy behaviour through the exe manifest, like they already do for long paths: https://docs.microsoft.
by skissane 5y ago
Maybe Microsoft could give apps a way to opt out of this legacy behaviour through the exe manifest, like they already do for long paths: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd https://docs.microsoft.com/en-us/windows/win32/fileio/maximu...
For system apps like cmd.exe or explorer.exe, a registry key would be a better solution. That way the end user or sys admin can turn it on or off, whereas the exe manifest is fixed at build time.
- p_l 5y agoIf you use UNC paths, it already happens. The issue is dealing with software that won't give absolute UNC (NT-native) path to an API. That said, it should be theoretically possible, but I believe any approach other than hooking into high level IO call will be problematic, and you'd probably lose access to many things like serial/parallel ports etc. (as applications wouldn't know the names you renamed them under).
- skissane 5y ago> and you'd probably lose access to many things like serial/parallel ports etc. (as applications wouldn't know the names you renamed them under). The big problem here is bare device names, and device names with an extension – e.g. "COM1", "COM1.TXT". Device names with a colon, e.g. "COM1:", are not such a big problem, because colon is not an allowed character in file names on Windows (it is reserved as syntax to specify a drive or stream.) And while colon is a valid character in Unix file names, it is rarely used in practice, so Windows not supporting it is less of a problem than Windows not supporting files named "aux" or "con" is. So if they still recognised the device names with a colon, that would work fine for some programs that already use the colon, and for those that don't it should be an easy fix to just add it before updating the EXE manifest to opt-in to this feature. Actually there is another fix – in Win32 programming you are recommended to prefix device names with "\\.\" anyway. That is actually mandatory when dealing with more than 9 serial ports (e.g there are multiport serial cards with more than 10 ports, or you might have two 8-port serial cards in your system). If you want to access COM10, you have to prefix it with "\\.\". And it is best practice to use those prefixes even with COM1-9. So programs already following that best practice would need no change. (And few programs directly use serial or parallel ports nowadays anyway.)
- PaulDavisThe1st 5y agoActually, colon (:) is allowed as part of a Windows file name. This changed at some point (presumably NT). However, almost all Windows tools will be incapable of dealing with a file name that includes a colon, even though the file exists on disk. We ran into this recently when a bug in Ardour ended up creating files on disk named like "recorder:N". They were created correctly on the disk, and in the Ardour instance that had created them and thus had file handles for them, they could be read without issues. But ... close the program and restart it ... errors about not being able to find the files. Fortunately, Notepad (I think) is one of the few applications that can handle these names (I have no idea why), and so it could be used to open and save the files under a "better" name. ps. after 35 years in computing, I have not used Windows for more than 30 minutes in total. This account is based on being a developer of a cross-platform application who reads bug reports and interacts with users.
- skissane 5y ago> Actually, colon (:) is allowed as part of a Windows file name. This changed at some point (presumably NT). However, almost all Windows tools will be incapable of dealing with a file name that includes a colon, even though the file exists on disk. I think you are getting confused by stream names. If you try to create a file called "foo1.txt:bar", some Windows tools let you. But that is not an example of a file name containing a colon. The filename is "foo1.txt". In Windows NT (and its successors), a file can be composed of multiple named streams, and ":" separates the file name from the stream name. So "foo1.txt:bar" is actually the the stream named "bar" of the file named "foo1.txt", not a file named "foo1.txt:bar"
- PaulDavisThe1st 5y agoThanks for the clarification. So let me rephrase. An application can attempt to create a file using the name "foo:bar" and this will result in a new entity in the filesystem that can sometimes be successfully accessed using the name "foo:bar", but generally not.
- 5y ago
- wvenable 5y agoThe problem is you could create the file in one program but not be able to read it the other. I wonder if they should only exist for command line apps although I wonder if there aren't still GUI apps that control industrial machinery by opening "COM1" as a file.
- int_19h 5y agoThis is already the case - if the app uses NT APIs directly rather than Win32, it can create files with "forbidden" names quite easily.
- skissane 5y agoYou don't even need to use the NT APIs directly. The Win32 APIs already do it if you use the \\?\ prefix. You can even demonstrate this with cmd.exe (which uses the Win32 API, it doesn't directly access the NT API) `mkdir c:\con` will not work, says `The directory name is invalid.` `mkdir \\?\c:\con` does work. But then to delete you have to use the \\?\ prefix again. And `cd \\?\c:\con\` doesn't work, you get the `CMD does not support UNC paths as current directories` error. (Win32 does, this is a cmd.exe limitation only) My proposal was to have a way of getting the `\\?\` behaviour without having to explicitly provide that prefix. Actually, not quite. There is one aspect of `\\?\` which is undesirable. The NT API only supports backslash as a directory separator. The Win32 API supports forward slash as well, it automatically converts forward slash to backslash. But `\\?\` turns that conversion off. I think you'd still want the forward to backslash conversion on, to maximise compatibility with Unix.
- int_19h 5y agoThe reason why it's not quite so simple is because any existing API that uses TCHAR[MAX_PATH] would be ABI-broken. Some of them are obvious, e.g. the WIN32_FIND_DATA struct used by FindFirstFile/FindNextFile. The less obvious part is that for a very long time, it has been a contract for all Win32 functions that return PATHs, that the maximum size of the returned path is MAX_PATH. So there are a lot of apps that basically allocate a buffer of that size and assume that it'll always be enough. So functions like GetFullPathName can't just start returning longer names, because it would break those apps. Instead, they rely on the presence of "\\?\" prefix in the input path as an indicator that the calling app understands those longer paths, and is ready to accept them as outputs as well.
- Asooka 5y agoI'd say the better solution is to restrict the feature to only cmd.exe and batch scripts. I am willing to bet that anyone who needs to use it outside of those two cases is running Windows on hardware that doesn't permit software updates and is probably not running anything newer than Windows XP (or even 95). If anybody knows of anyone using those special files in programs running on modern Windows, I'd love to hear about it.
- skissane 5y agoI reckon somewhere out there, is some obscure program used to control some piece of scientific or industrial equipment, and it talks to that equipment over COM1, and it is just opening "COM1" as opposed to "COM1:" or "\\.\COM1", and it still runs on Windows 10. Rare scenario, few people are going to be impacted by it, but probably somewhere out there is someone who will be. And making it a registry key or EXE manifest option helps to not break that rare software. And I wouldn't assume that systems connected to laboratory or industrial equipment don't get Windows updates; some don't, some do.
- sixothree 5y agoI very much wish Excel had a "I could not care less about legacy crap and I never ever want to see my number converted to scientific notation again for as long as I freaking live so help me I want to kick those devs in the goshdarn shin" mode.
- suzzer99 5y ago"1/2 cup margarine" - Excel: Is this a date? "2011-10-05T14:48:00.000Z" - Excel: I have no idea what this is.
- WorldMaker 5y agoThe "Number Format" panel is front and center in the Excel ribbon. Just use anything but "General" and you get the "I don't want you automatically guessing mode". Ctrl+A then Alt H N T E enter to make the whole spreadsheet "Text" by default instead of "General". (Or Ctrl+A Alt H N A enter to default everything to "Accounting" if you are just going to be typing in a bunch of dollar amounts, etc.) The tools are there to "opt out" of "I'm too lazy to set a data type so guess for me" mode and always have been.
- sixothree 5y agoI am so sick of these answers. I am tired of changing the formatting. So. Freaking. Tired. I never, EVER, want to see another number in scientific notation unless I tell it too.