From d1283eca04b3260195c21ab1be452cb0b63db061 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Sat, 3 Mar 2012 22:19:24 -0500 Subject: [PATCH] Added DirCreate (creates entire tree) returns true/false --- mdl/m_fileio.pas | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mdl/m_fileio.pas b/mdl/m_fileio.pas index bba04a7..d348d1f 100644 --- a/mdl/m_fileio.pas +++ b/mdl/m_fileio.pas @@ -31,6 +31,7 @@ Function JustFileName (Str: String) : String; Function JustFile (Str: String) : String; Function JustFileExt (Str: String) : String; Function JustPath (Str: String) : String; +Function DirCreate (Str: String) : Boolean; Function DirExists (Str: String) : Boolean; Function DirSlash (Str: String) : String; Function DirChange (Dir: String) : Boolean; @@ -283,6 +284,37 @@ Begin Result := (IoResult = 0); End; +Function DirCreate (Str: String) : Boolean; +Var + Count : Byte; + CurDir : String; + Prefix : String; +Begin + Result := True; + Prefix := ''; + Str := DirSlash(Str); + + Count := Pos(PathSep, Str); + + While (Count > 0) Do Begin + CurDir := Copy(Str, 1, Count); + + Delete (Str, 1, Count); + + Prefix := Prefix + CurDir; + + If Not DirExists(Prefix) Then Begin + {$I-} MkDIR (Prefix); {$I+} + If IoResult <> 0 Then Begin + Result := False; + Exit; + End; + End; + + Count := Pos(PathSep, Str); + End; +End; + Procedure DirClean (Path: String; Exempt: String); Var DirInfo: SearchRec;