You'll have to uncomment the CreateDirectory line for it to actually work, but run as is in Debugger to see how it would work in action. Of course, IF the drive exists it will fail to create the root directory. To be expected:
Procedure Makepath(Sample$)
Sample$ = Trim(Sample$, "\")
Path$ = ""
For D = 1 To CountString(Sample$, "\") + 1
Path$ + StringField(Sample$, D, "\") + "\"
If FileSize(Path$) = -1
Debug Path$
; CreateDirectory(Path$)
Else
Debug Path$+" already exists"
EndIf
Next D
EndProcedure
;Examples with and without trailing \
Makepath("D:\Eat\At\Joes\Bar\And\Grill\")
Delay(3000)
Makepath("D:\Eat\At\Joes\Bar\And\Grill")
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
I'm, guessing change backslash to forward slash for Linux or MAC in my procedure to get it to work there. Cannot test here.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
Randy Walker wrote: Tue Mar 10, 2026 9:08 am
I'm, guessing change backslash to forward slash for Linux or MAC in my procedure to get it to work there. Cannot test here.
Fun Fact: It's on the Deprecated APi Section since more than 10 years now.
SHCreateDirectory is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.
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).
Not on Mac: you cannot create a dir if there's a file with the same name (at least not on Finder… don't wanna risk to try with PB and nuke my filesystem )
Fun Fact: It's on the Deprecated APi Section since more than 10 years now.
SHCreateDirectory is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.
Yes, thats a good one, too.
And reading the comments section is even more fun.
Remarks
Each directory specified is created, if it does not already exist. If only some of the directories are created, the function will return FALSE.
This function does not support Unicode strings. To specify a Unicode path, use the SHCreateDirectoryEx function.
All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more than one thread to this function.
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).
Axolotl wrote: Wed Mar 11, 2026 5:04 pm
Yes, thats a good one, too.
And reading the comments section is even more fun.
Remarks
Each directory specified is created, if it does not already exist. If only some of the directories are created, the function will return FALSE.
This function does not support Unicode strings. To specify a Unicode path, use the SHCreateDirectoryEx function.
All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more than one thread to this function.
I don't know or understand Unicode Well enough to write code that supports it and as far as I'm concerned, don't have any use for it. Feel free to provide what you would consider to be a superior Procedure. I wont be offended. If you're comfortable using the SHCreate thing, that's fine too. Seems if the end user of your code doesn't have the Dbghelp.lib then your code will fail, Also from the official MS website: "This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable in subsequent versions of Windows."
So bottom line seems to be: Your SHCreate thing may not be the best possible path. No pun intended.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.