Code: Select all
Debug FileSize("c:\windows\\\\\system32\\\\\") ; -2 (why valid?)
Code: Select all
Debug FileSize("c:\windows\\\\\system32\\\\\") ; -2 (why valid?)
Code: Select all
Debug "c:\windows\\\\\system32\\\\\"
If FileSize("c:\windows\\\\\system32\\\\\") = -2
Debug "Purebasic thinks it's a DIRECTORY"
EndIf
#GetFileExInfoStandard = 0
GetFileAttributesEx_("c:\windows\\\\\system32\\\\\", #GetFileExInfoStandard, r.WIN32_FILE_ATTRIBUTE_DATA )
If r\dwFileAttributes = #FILE_ATTRIBUTE_DIRECTORY
Debug "WINAPI thinks it's a DIRECTORY ... too"
Else
Debug "Shame on you, Purebasic"
EndIf
Code: Select all
Debug "c:\windows\\\\\system32\\\\\"
If FileSize("c:\windows\\\\\system32\\\\\") = -2
Debug "Purebasic thinks it's a DIRECTORY"
EndIf
#GetFileExInfoStandard = 0
GetFileAttributesEx_("c:\windows\\\\\system32\\\\\", #GetFileExInfoStandard, r.WIN32_FILE_ATTRIBUTE_DATA )
If r\dwFileAttributes = #FILE_ATTRIBUTE_DIRECTORY
Debug "WINAPI thinks it's a DIRECTORY ... too"
Else
Debug "Shame on you, Purebasic"
EndIf
;:: the standard purebasic procedure returns the flag as well
If GetFileAttributes("c:\windows\\\\\system32\\\\\") & #FILE_ATTRIBUTE_DIRECTORY
Debug "GetFileAttributes() thinks it's a DIRECTORY ... too"
EndIf
Debug "the end"
; == Debug Output ==
; c:\windows\\\\\system32\\\\\
; Purebasic thinks it's a DIRECTORY
; WINAPI thinks it's a DIRECTORY ... too
; GetFileAttributes() thinks it's a DIRECTORY ... too
; the end
Code: Select all
Define buffer$ = Space(#MAX_PATH)
Debug GetFullPathName_("c:\windows\\\\\system32\\\\\", #MAX_PATH, @buffer$, 0)
Debug " '"+buffer$+"'"
;:: == Debug Output ==
;::20
;:: 'c:\windows\system32\'
Code: Select all
countItems = 0 ;:: save some time
maxItems = 10 ;:: do not show all files and directories
;:: the example from Help with the special directory
If ExamineDirectory(0, "c:\windows\\\\\system32\\\\\", "*.*")
Debug "begin"
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
Type$ = "[File] "
Size$ = " (Size: " + DirectoryEntrySize(0) + ")"
countItems + 1
Else
Type$ = "[Directory] "
Size$ = "" ; A directory doesn't have a size
EndIf
Debug Type$ + DirectoryEntryName(0) + Size$
If countItems > maxItems
Break
EndIf
Wend
Debug "finish"
FinishDirectory(0)
EndIf
Code: Select all
Debug "c:\windows\\\\\system32\\\\\"
If FileSize("c:\windows\\\\\system32\\\\\") = -2
Debug "Purebasic FileSize() thinks it's a DIRECTORY"
EndIf
;:: the standard purebasic procedure returns the flag as well
If GetFileAttributes("c:\windows\\\\\system32\\\\\") & #FILE_ATTRIBUTE_DIRECTORY
Debug "GetFileAttributes() thinks it's a DIRECTORY"
EndIf
; Win API method
#GetFileExInfoStandard = 0
GetFileAttributesEx_("c:\windows\\\\\system32\\\\\", #GetFileExInfoStandard, r.WIN32_FILE_ATTRIBUTE_DATA )
If r\dwFileAttributes = #FILE_ATTRIBUTE_DIRECTORY
Debug "WINAPI thinks it's a DIRECTORY ... too"
Else
Debug "Shame on you, Purebasic"
EndIf
Define buffer$ = Space(#MAX_PATH)
GetFullPathName_("c:\windows\\\\\system32\\\\\", #MAX_PATH, @buffer$, 0)
Debug "GetFullPathName_() shows "+buffer$
; == Debug Output ==
; c:\windows\\\\\system32\\\\\
; Purebasic FileSize() thinks it's a DIRECTORY
; GetFileAttributes() thinks it's a DIRECTORY ... too
; WINAPI thinks it's a DIRECTORY ... too
; GetFullPathName_() shows c:\windows\system32\
Open a terminal and try "cd C:\\\\\\\\Windows", it works fineMost operating systems allow the inclusion of multiple slashes between file name or directory components of a file path. This is true of both Windows and most *nix operating systems. The only exception is slashes used in conjunction with a UNC, where only two backward slashes are allowed with the UNC (\\?\UNC\).
You can use consecutive Slashes on Linux too:
Code: Select all
Debug FileSize("///home/nicolas/////////tmp")
Code: Select all
nicolas@Rocky:~/.config$ LANG=C stat //////home/nicolas/////tmp
File: //////home/nicolas/////tmp
Size: 20480 Blocks: 40 IO Block: 4096 directory
Device: fd00h/64768d Inode: 54526167 Links: 61
Access: (0755/drwxr-xr-x) Uid: ( 1000/ nicolas) Gid: ( 100/ users)
Access: 2021-03-29 14:48:04.537557642 +0200
Modify: 2022-01-03 20:09:19.075796438 +0100
Change: 2022-01-03 20:09:19.075796438 +0100
Birth: 2021-03-29 14:48:04.537557642 +0200