CheckFileName()

Just starting out? Need help? Post your questions and find answers here.
User avatar
the.weavster
Addict
Addict
Posts: 1577
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

CheckFileName()

Post by the.weavster »

PB 6.20 on MX Linux (Debian)

This returns zero:

Code: Select all

Debug CheckFilename("/home")
I can't currently check other platforms...

// Moved from "Bugs - Linux" to "Coding Questions" (Kiffi)
AZJIO
Addict
Addict
Posts: 2175
Joined: Sun May 14, 2017 1:48 am

Re: CheckFileName()

Post by AZJIO »

The "/" symbol forbidden in the name
User avatar
the.weavster
Addict
Addict
Posts: 1577
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: CheckFileName()

Post by the.weavster »

Ah, so it only checks the file name bit :oops:
I was using it to check a whole path string :lol:
AZJIO
Addict
Addict
Posts: 2175
Joined: Sun May 14, 2017 1:48 am

Re: CheckFileName()

Post by AZJIO »

Then you need FileSize()
User avatar
the.weavster
Addict
Addict
Posts: 1577
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: CheckFileName()

Post by the.weavster »

AZJIO wrote: Sun Feb 23, 2025 6:56 pm Then you need FileSize()
The path / file may not exist (yet), it's a string coming in from a script and I'm trying to perform a sanity check to make sure it could reasonably be interpreted as a path for the current OS.
Quin
Addict
Addict
Posts: 1132
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: CheckFileName()

Post by Quin »

the.weavster wrote: Sun Feb 23, 2025 9:03 pm The path / file may not exist (yet), it's a string coming in from a script and I'm trying to perform a sanity check to make sure it could reasonably be interpreted as a path for the current OS.
CheckFileName() is what you want in this case, but the "/" character isn't allowed on Windows, so I think this function disallows it globally. As it turns out though, that's also the character separator on Linux...
At least on Windows it works for full paths using backslash.
Perhaps the "/" check should be limited to Windows only in PB itself?
Post Reply