Code: Select all
Debug GetExtensionPart("X:\A\A\B\A\B\GTI\A\.tproject")

Is it a bug ?
Have a good day
Moderator: Documentation Editors
Code: Select all
Debug GetExtensionPart("X:\A\A\B\A\B\GTI\A\.tproject")
Code: Select all
; Linux GetExtensionPart does not recognize file names ending with a backslash.
Filename$="X:\A\A\B\A\B\GTI\A\.tproject"
Debug "GetFilePart:"+GetFilePart(Filename$)
Debug "GetFilePart #PB_FileSystem_NoExtension:"+GetFilePart(Filename$,#PB_FileSystem_NoExtension)
Debug "GetExtensionPart:"+GetExtensionPart(Filename$)
Filename$="A\.svg"
Debug "GetExtensionPart:"+GetExtensionPart(Filename$)
; GetFilePart:X:\A\A\B\A\B\GTI\A\.tproject
; GetFilePart #PB_FileSystem_NoExtension:X:\A\A\B\A\B\GTI\A\
; GetExtensionPart:
; GetExtensionPart:
; kulow@kulow-G73Jw:~$ ls X*.tproject
; 'X:\A\A\B\A\B\GTI\A\.tproject'
; kulow@kulow-G73Jw:~$ ls A*.svg
; 'A\.svg'
Yes you have right, but here it's not really the subject, hidden or not, it's a normal file, he have not name but have a real extension like others, then why it not treaty like the others ?Fred wrote: Mon Jun 03, 2024 9:11 am such files are usually hidden files name, which are not really extension only.
We cannot change a rule, the fault of another parameter existFred wrote:We could add to GetExtensionPart() and GetFilePart() than a filename starting with a dot '.' (like .htaccess) is considered as a filename and not as an extension as these kind of name are very commonly used to design 'hidden' files
Code: Select all
Procedure.s GetExtensionPartEx(File.s)
Name$ = GetFilePart(File)
Extension$ = GetExtensionPart(File)
If Trim(Extension$) = "" And Left(Name$, 1) = "."
Extension$ = Mid(Name$, 2)
EndIf
ProcedureReturn Extension$
EndProcedure
Debug GetExtensionPartEx("X:\A\A\B\A\B\GTI\A\.txt")
Code: Select all
Debug GetFilePart(".bashrc.zip")# Outputs .bashrc.zip
Code: Select all
Debug GetExtensionPart(".bashrc.zip")# Outputs .zip
Code: Select all
Procedure.s GetFileExtension(file$)
ext$=GetExtensionPart(file$)
If LCase(ext$)=LCase(file$)
ext$=""
EndIf
ProcedureReturn ext$
EndProcedure
Debug GetFileExtension("X:\A\A\B\A\B\GTI\A\file.tproject") ; "tproject"
Debug GetFileExtension("X:\A\A\B\A\B\GTI\A\.tproject") ; ""
Debug GetFileExtension(".htaccess") ; ""
Code: Select all
; Your Expectation: ".tproject" is an extension instead of an filename
;
Global TestFilename$ = "X:\A\A\B\A\B\GTI\A\.tproject"
Procedure.s GetExtensionPartEx(FullPathName$)
Protected result$, e$, f$
e$ = GetExtensionPart(FullPathName$)
f$ = GetFilePart(FullPathName$)
If e$ = "" And Left(f$, 1) = "."
If Right(f$, 1) = "."
result$ = e$
Else
result$ = Mid(f$, 2)
EndIf
Else
result$ = e$
EndIf
ProcedureReturn result$
EndProcedure
; the proof is in the pudding ....
;
Macro Test_FullPathName(Filename)
Debug "Filename = " + Filename
Debug " Ext = " + GetExtensionPart(Filename)
Debug " File = " + GetFilePart(Filename)
Debug " Ext.Ex = " + GetExtensionPartEx(Filename)
Debug ""
EndMacro
; the pudding ....
;
Test_FullPathName( "X:\A\A\B\A\B\GTI\A\.tproject" )
Test_FullPathName( "X:\A\A\B\A\B\GTI\A\a.tproject" )
Test_FullPathName( "X:\A\A\B\A\B\GTI\A\.tproject.a" )
Test_FullPathName( "X:\A\A\B\A\B\GTI\A\.tproject." )
I don't accept that as a definition. According to ChatGPT, there is no official convention as to whether dotfiles have an empty file name or whether everything is the file name.Michael Vogel wrote: Mon Jun 03, 2024 5:26 pm "The .htaccess file is always named .htaccess and does not include a filename before the dot"
https://fileinfo.com/extension/htaccess
Axolotl wrote:; the proof is in the pudding ....