Page 3 of 3
Re: CreateDirectory() recursively or CreatePath()
Posted: Fri Jan 08, 2021 5:38 pm
by NicTheQuick
skywalk wrote:Yes, that makes sense. I am merely trying to maintain compatibility with Windows transfers between Linux servers.
The biggest issues I have with common directories between Linux and Windows are the characters ":", "?" and the double quotation mark. I use them quite often. Also it is annoying that Windows does not care about lower and upper case characters.
Re: CreateDirectory() recursively or CreatePath()
Posted: Fri Jan 08, 2021 5:47 pm
by skywalk
My approach is KISS. The filenames just have to be unique without so much information conveyed. The contents are what matters.
Re: CreateDirectory() recursively or CreatePath()
Posted: Tue Aug 13, 2024 10:11 am
by AZJIO
I made an improvement to the
ForceDirectories function
Code: Select all
Procedure ForceDirectories(Dir.s)
Static tmpDir.s, Init
Protected result
If Asc(Dir)
If Not Init
tmpDir = Dir
Init = 1
EndIf
Dir = RTrim(Dir, #PS$)
If FileSize(Dir) = -2 Or (Len(Dir) < 3) Or GetPathPart(Dir) = Dir
If FileSize(tmpDir) = -2
result = -1
EndIf
tmpDir = ""
Init = 0
ProcedureReturn result
EndIf
ForceDirectories(GetPathPart(Dir))
ProcedureReturn CreateDirectory(Dir)
Else
ProcedureReturn 0
EndIf
EndProcedure
1. #PS$ makes it cross-platform
2. If FileSize(Dir) = -2 moved to the beginning, since most people use it as a criterion
3. Dir = RTrim(Dir, #PS$) - eliminated the character check and immediately trimmed it so as not to check it twice
4. Asc(Dir) is faster than Len(Dir)
5. result = -1 ; additional information about the fact that the folder already exists without using CreateDirectory(Dir)