Just starting out? Need help? Post your questions and find answers here.
Piero
Addict
Posts: 862 Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy
Post
by Piero » Fri Jul 18, 2025 12:48 pm
Code: Select all
; This (Mac/Linux) bug is very unlikely to happen and cause big problems, but I had to report…
Debug GetFilePart(~"/folder/a\"b") ; result: a
Edit (to be more clear): double quotes are allowed in Mac/Linux file names
Last edited by
Piero on Fri Jul 18, 2025 3:13 pm, edited 2 times in total.
BarryG
Addict
Posts: 4118 Joined: Thu Apr 18, 2019 8:17 am
Post
by BarryG » Fri Jul 18, 2025 1:18 pm
Same result on Windows.
jacdelad
Addict
Posts: 1991 Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa
Post
by jacdelad » Fri Jul 18, 2025 1:36 pm
Maybe because " is not allowed on windows?
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Axolotl
Enthusiast
Posts: 797 Joined: Wed Dec 31, 2008 3:36 pm
Post
by Axolotl » Fri Jul 18, 2025 1:40 pm
AFAIK the #DoubleQuote is not a vaild character in a filename, on windows, / and \ are now treated equally and they are not allowed in a filename, too.
Code: Select all
Debug CheckFilename(~"a\"b") ; result: 0 on windows
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home . Now started with Linux (VM: Ubuntu 22.04 ).
Piero
Addict
Posts: 862 Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy
Post
by Piero » Sat Jul 19, 2025 5:09 am
Code: Select all
; Workaround for GetFilePart bug
Procedure.s CheckGetFilePart(p$,ne=#PB_FileSystem_NoExtension)
Protected pp$ = GetPathPart(p$), fp$ = GetFilePart(p$)
If StringByteLength(pp$+fp$) <> StringByteLength(p$)
ProcedureReturn ""
EndIf
ProcedureReturn GetFilePart(p$,ne)
EndProcedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
s.s= CheckGetFilePart(~"/folder/a\"b")
Debug "Result: "+ s
s= CheckGetFilePart("/folder/ab.txt", 0)
Debug "Result: "+ s
s= CheckGetFilePart("ab.txt")
Debug "Result: "+ s
collectordave
Addict
Posts: 1310 Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal
Post
by collectordave » Mon Jul 21, 2025 2:10 pm
Debug GetFilePart(~"/folder/a/b")
Works on MAC
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Piero
Addict
Posts: 862 Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy
Post
by Piero » Mon Jul 21, 2025 2:35 pm
collectordave wrote: Mon Jul 21, 2025 2:10 pm
Debug GetFilePart(~"/folder/a/b")
Works on MAC
You don't need ~ for "/folder/a/b", but you need it for ~"/folder/a\"b" (~" \" " is to put a double quote into a string)