- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This is going to work fantastically well if someone creates a file on unix that contains a backslash in it's name.
Admin
Just use / for all your path-separators, Windows can handle those just fine.
Admin
User code with backslashes as path separators is an abomination. Low level C/C++ file operations support, and have always supported, backslashes.
Slight exception for the presentation layer, because users expect backslashes. But only the presentation layer. Convert to backslashes on output, convert to forward slashes on input.
Edit Admin
In my decades of software development, different file IO systems were always a pain in the butt. Now these days a lot of people only think there are two but in the past there were many different ones and all of them had a quirk here and there.
Still, while Windows supports both directory separators, it's very important to note that this support means that all alternative directory separators are actually get converted (normalized) before usage internally and since all functions support const literals that means allocating a buffers. So there is a significant cost involved with using alt directory separators and you still should always use the native versions over the common '/'.
Now is there a good way to get around this? Nah. There is actually way more to it than just the directory separator since file systems are often completely different in terms of structure and features. Linux is real links and ignoring that could end up in an endless recursion why enumerating directories. Windows had drives, which are not only not bound to letters that can change, they actually often will when you work with multiple removable devices. And finally the whole permission system is completely different, down to what classifies as an executable. And I just mentioned here a few pitfalls on the top of the iceberg. So just using an directory separator macro isn't enough in a well thought out software, you really need to abstract away the OS in a way more involved way to the point that it's really hard to pull this off on a zero cost basis; which means it's often better to do it inline. Sucks for readability, sure, but beats using a bloated, slow, resource hungry IO framework.
Addendum 2026-06-29 08:01: Linus is real links? Ha, I guess it has them but eh, I blame the heat wave here :-).
Admin
Ah, the good old XKCD 1638...
Edit Admin
You people had it soft. Welcome to the world of VMS, a.k.a. OpenVMS, in which the directory separator is a period but the entire directory name had to be enclosed in square brackets.
And that's just getting started. There was a limit of subdirectory levels (8) but a "logical name" could be defined to sneak around that --- for example, DISK1 might expand to a physical hard drive like DKA0 but it could easily expand to DKA0:[CLIENTS.BESTBUY.CONTRACTS.MAINTENANCE.2020.] instead. Loads of fun for the entire family!
Edit Admin
Indeed, although it is stretching the definition of "modern" a bit, seeing as how all versions of Windows in the NT line supported it, all the way back to 3.1, and the 9x line also supported it. It probably worked (it has been too long since I've needed to know this) on MS-DOS as early as 2.0. (Before that, directory structures weren't a thing on MS-DOS, nor on PC-DOS.)
Edit Admin
Don't forget the file versions!
README.TXT;3lets you see what the file looked like three versions ago.Back when I worked helldesk in college, our mailserver ran off a VAX running VMS. They added a webmail interface in 1998 or 1999 (before that you were expected to just use IMAP or POP), but it was still the same mailserver. And due to the way it worked, you'd get locked out of your account if you exceeded your quota, which meant you couldn't log into the webmail to delete your emails. One of the main tickets for the helldesk drones was telneting into the mailserver using the user's credentials and using the
mailCLI tool to clear out old messages.Admin
There are a couple of exceptions. (1) Command line options start with "/". (2) Dialog boxes insist on backslashes.