Page 1 of 1

CreateDirectoryEx (crossplattform)

Posted: Fri Jan 10, 2014 2:15 pm
by ts-soft
a very simple way to create all dirs at once
(MacOS not tested)

Code: Select all

EnableExplicit

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
CompilerElse
  ImportC ""
    system(cmd.p-utf8)
  EndImport
CompilerEndIf

Procedure CreateDirectoryEx(DirPath.s)
  CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Windows
    RunProgram(GetEnvironmentVariable("COMSPEC"), "/c mkdir " + #DQUOTE$ + DirPath + #DQUOTE$, "", #PB_Program_Wait | #PB_Program_Hide)
    If FileSize(DirPath) = -2
      ProcedureReturn #True
    EndIf
  CompilerDefault
  If Not system("mkdir -p " + #DQUOTE$ + DirPath + #DQUOTE$)
    ProcedureReturn #True
  EndIf
  CompilerEndSelect
EndProcedure

Define.s Path = GetHomeDirectory() + "test1/test2/tesatäöü"


Debug CreateDirectoryEx(Path)

Re: CreateDirectoryEx (crossplattform)

Posted: Sat Jan 11, 2014 4:03 am
by rsts
Very useful.

Thanks for sharing :)

Re: CreateDirectoryEx (crossplattform)

Posted: Mon Jan 13, 2014 9:48 am
by Kwai chang caine
Thanks Ts-Soft 8)
Just a question, what is the difference with MakeSureDirectoryPathExists_() ?

Re: CreateDirectoryEx (crossplattform)

Posted: Mon Jan 13, 2014 10:26 am
by ts-soft
Kwaï chang caïne wrote:Thanks Ts-Soft 8)
Just a question, what is the difference with MakeSureDirectoryPathExists_() ?
MakeSureDirectoryPathExists_ is not Unicode compatible and not available on all Win Versions.

Re: CreateDirectoryEx (crossplattform)

Posted: Mon Jan 13, 2014 11:58 am
by Kwai chang caine
and not available on all Win Versions.
Waoouuuh!!! fortunately i ask you this question.... :shock:
Because i use it frequently, and don't know it's possible a day that don't work everywhere

Again thanks TsSoft, for the sharing and your answer 8)

Re: CreateDirectoryEx (crossplattform)

Posted: Mon Jan 13, 2014 12:06 pm
by ts-soft
It is only missing on some UserDefined Win9x installation, not a problem in 2014 :wink:

Re: CreateDirectoryEx (crossplattform)

Posted: Mon Jan 13, 2014 12:52 pm
by Kwai chang caine
Always good to know this missing, even if win 9x are far now...because again numerous PC works with 8)
The problem with the API, it's sometime she change and bill gates never ask at KCC if he have the right :mrgreen: :lol:
And it's like when, i have learning, thanks to the PB members, PathAddBackslash_(@Var) can be dangerous :shock:
The API are powerfull, but it's important to know her, before use it :oops:
Thanks for your tips 8)