GetFilepart bug
Re: GetFilepart bug
You're right, that's what I meant.
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
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
-
- Enthusiast
- Posts: 581
- Joined: Wed Sep 25, 2019 10:18 am
{BUG Linux and Windows]Re: GetFilepart and GetExtensionPart bug
Linux:
Windows:

Code: Select all
-rw-rw-r-- 1 kulow kulow 147 Nov 27 13:30 ..png
-rw-rw-r-- 1 kulow kulow 147 Nov 27 13:30 .png
-rw-rw-r-- 1 kulow kulow 147 Nov 27 13:30 .Test.png
Code: Select all
; Extension of Filename /tmp/.png
Procedure.s FileDetail(FileName.s)
ProcedureReturn FileName+" Size:"+FileSize(FileName)+" Path:"+GetPathPart(FileName)+
" Name:"+GetFilePart(FileName)+
" Name(NoExtension):"+GetFilePart(FileName,#PB_FileSystem_NoExtension)+
" Extension:"+ GetExtensionPart(FileName)
EndProcedure
Debug FileDetail("/tmp/.png")
Debug FileDetail("/tmp/..png")
Debug FileDetail("/tmp/.Test.png")
; /tmp/.png Size:147 Path:/tmp/ Name:.png Name(NoExtension):.png Extension:
; ^^^^ ^
; /tmp/..png Size:147 Path:/tmp/ Name:..png Name(NoExtension):. Extension:png
; /tmp/.Test.png Size:147 Path:/tmp/ Name:.Test.png Name(NoExtension):.Test Extension:png

Code: Select all
D:\tmp>dir /B
.Test.png
.png
..png
Code: Select all
; Extension of Filename d:\tmp\.png
Procedure.s FileDetail(FileName.s)
ProcedureReturn FileName+" Size:"+FileSize(FileName)+" Path:"+GetPathPart(FileName)+
" Name:"+GetFilePart(FileName)+
" Name(NoExtension):"+GetFilePart(FileName,#PB_FileSystem_NoExtension)+
" Extension:"+ GetExtensionPart(FileName)
EndProcedure
Debug FileDetail("d:\tmp\.png")
Debug FileDetail("d:\tmp\..png")
Debug FileDetail("d:\tmp\.Test.png")
; d:\tmp\.png Size:147 Path:d:\tmp\ Name:.png Name(NoExtension):.png Extension:
; ^^^^ ^
; d:\tmp\..png Size:147 Path:d:\tmp\ Name:..png Name(NoExtension):. Extension:png
; d:\tmp\.Test.png Size:147 Path:d:\tmp\ Name:.Test.png Name(NoExtension):.Test Extension:png
-
- User
- Posts: 65
- Joined: Wed Jun 07, 2017 10:13 pm
Re: GetFilepart bug
Ok.... you are missing the pointLittle John wrote: Tue Nov 28, 2023 11:03 am an empty filename with an extension simply does not exist. That's by definition, and it doesn't matter whether or not someone likes it.
I already agreed that this is not a PB bug.
I agree that a filename can start with a dot.
I also agree that 'empty filename with an extension' can not exist.
The point is..... how do you detect the difference between 'an ERRONEUS empty file with an extention' OR 'a weired LEGAL filename with no extention'.
Anyway, I do a workaround, so no worry.
Case closed
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: GetFilepart bug
I know. And I took the liberty of confirming it.
You are right. I am missing your point, since you are artificially creating a problem that does not actually exist:williamvanhoecke wrote: Wed Nov 29, 2023 2:16 pm The point is..... how do you detect the difference between 'an ERRONEUS empty file with an extention' OR 'a weired LEGAL filename with no extention'.
First check the user input BEFORE automatically appending something to it. If it's empty, then it's an error.williamvanhoecke wrote: Mon Nov 27, 2023 11:31 pm I have this software where customer enter a raw 'name' for there file and the extention is then automatically added.
I then check is a 'name' was entered and if it is valid with CheckFilename(name).
So i get things like "C:\user\benjamin\customerfiles\.lti"