
Code:
Sub CheckDir(TestDir As String) CALL MakeSureDir(BYVAL STRPTR(TestDir)) End Sub
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Sub CheckDir(TestDir As String) CALL MakeSureDir(BYVAL STRPTR(TestDir)) End Sub
Declare Function MakeSureDir LIB "IMAGEHLP.DLL" Alias "MakeSureDirectoryPathExists" (lpDirName As Asciiz) As Long Sub CheckDir(TestDir As String) Dim RetVal As Long Dim DirPath As Asciiz * MAX_PATH ' The ending backslash is necessary DirPath = TestDir & Chr$(0) RetVal = MakeSureDir(DirPath) End Sub
SUB BuildDir (BYVAL Path$) drive$="" 'Strip off trailing backslash IF RIGHT$(Path$,1)="\" THEN Path$=MID$(Path$,1,LEN(Path$)-1) END IF 'Check for UNC Path and make drive$ = to machine name IF MID$(Path$,1,2)="\\" THEN temp_pos&=instr(3,Path$,"\") drive$=mid$(Path$,1,temp_pos&-1) Path$=MID$(Path$,len(drive$)+2) root&=1 ELSE IF MID$(Path$,1,1)="\" THEN Path$=MID$(Path$,2) root&=1 END IF END IF IF MID$(Path$,2,1)=":" THEN drive$=MID$(Path$,1,2) Path$=MID$(Path$,3) IF MID$(Path$,1,1)="\" THEN Path$=MID$(Path$,2) root&=1 END IF END IF 'Loop through path building directories as needed.... FOR i&=1 TO LEN(Path$) c$=MID$(Path$,i&,1) IF c$="\" THEN ON ERROR RESUME NEXT IF root& THEN MKDIR drive$+"\"+a$ ELSE MKDIR a$ END IF ON ERROR GOTO 0 END IF a$=a$+c$ NEXT i& ON ERROR RESUME NEXT IF root& THEN MKDIR drive$+"\"+a$ ELSE MKDIR a$ END IF ON ERROR GOTO 0 END SUB
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: