Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Backslash versus foreslash
#11
Code: (Select All)
pathsep$ = Mid$("/\", 1 - (Left$(_OS$, 4) = "[WIN"), 1)
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply
#12
It's unusual but you're actually allowed to have any character other than NUL or / in a filename on Linux. You can make valid filenames with a \, |, etc. in them, though it's a little harder to do.
Reply
#13
(01-11-2023, 09:38 PM)DSMan195276 Wrote: It's unusual but you're actually allowed to have any character other than NUL or / in a filename on Linux. You can make valid filenames with a \, |, etc. in them, though it's a little harder to do.

Oh, that sounds horrible. Who on Earth would consider putting a pipe or slash in their filename? Makes escaping stuff much harder.
Tread on those who tread on you

Reply
#14
(01-11-2023, 09:52 PM)Spriggsy Wrote: Oh, that sounds horrible. Who on Earth would consider putting a pipe or slash in their filename? Makes escaping stuff much harder.

In practice you basically never see it because lots of programs won't like them, though for escaping on the shell it's not _too_ bad since you should be quoting your filenames anyway. But then some characters you might consider more "normal" (and are even allowed on Windows) can easily cause much bigger problems, such as dollar signs, so it is what it is. And of course filenames are typically some unicode format now, so that makes things even messier. In fact on Windows I don't believe filenames are even guaranteed to be _valid_ UTF-16, just a sequence of 2-byte pairs that look like UTF-16, you can put in any nonsense you want as long as it's not one of the few illegal characters. Generally speaking, the best way to handle filenames is to just treat them as an opaque sequence of bytes (besides the path separator) and never mess with them.

But case in point, if QB64 started automatically swapping backslashes for slashes then you could not open files on Linux that contain backslashes Tongue That kind of thing is why they're uncommon.
Reply
#15
I was going to use the colon in my example but no good since Windows still likes that for drive prefix. I used pipe symbol because someone on Unix who tries to create a filename with that or with colon or newline or some other strange character, is definitely behaving in malicious fashion.
Reply
#16
Ok, here is what I found out:

I installed the latest version of Linux Mint with all updates and the latest version of QB64PE.

The latest Linux version of QB64PE will only accept foreslashes. Using backslashes will not work.

The latest Windows version of QB64PE will accept both foreslashes and backslashes.

I currently have no way to test this on an Apple.
Reply
#17
(01-12-2023, 05:16 AM)TerryRitchie Wrote: I currently have no way to test this on an Apple.

Just for you to know, I just made a test on my iMAC-27 and was able to create a file with the crazy name "this is|my\address/book.txt" with a pipe sign and both the backslashe and forslashe and TextEdit opens and saves it without any problem.

Cheers.
Fifi
Before to send the arrow of truth, dip the head in a honey pot (Cheyenne saying).
Don't tell my Mom I'm on iMac with macOS, she thinks I work on PC with Windows. Tongue
Reply
#18
(01-14-2023, 07:59 AM)Fifi Wrote:
(01-12-2023, 05:16 AM)TerryRitchie Wrote: I currently have no way to test this on an Apple.

Just for you to know, I just made a test on my iMAC-27 and was able to create a file with the crazy name "this is|my\address/book.txt" with a pipe sign and both the backslashe and forslashe and TextEdit opens and saves it without any problem.

Cheers.
Fifi

Thank you for verifying Apple works. It looks to be a just a Linux glitch then.
Reply




Users browsing this thread: 2 Guest(s)