Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Par2: Recursively add/delete directories 2000-12-18 -- James Cooke Try this function to recursively create an entire subdir structure. I wrote
this yonks ago and has some legacy stuff in it but it works ok.
It is called like this: Makepath('c:\dir1\dir2\dir3\xyz.txt')
!Inside the global Map:
MODULE('WINAPI')
!!Prototype to play sound (requires equate for LPCSTR data type in After Global includes)
OMIT('***',_WIDTH32_)
fn_split(*CString,*CString,*CString,*CString,*CString),short,raw,name('_fnsplit')
MkDir(*CSTRING),SHORT,RAW,NAME('_mkdir')
End
***
COMPILE('***',_WIDTH32_)
fn_split(*CString,*CString,*CString,*CString,*CString),short,raw,name('_fnsplit')
MkDir(*CSTRING),SHORT,RAW,NAME('_mkdir')
***
END
!Function Variables:
MakePath FUNCTION (FullFileName) ! Declare Procedure
ThePath CSTRING(255)
TheDrive CSTRING(255)
TheDir CSTRING(255)
TheName CSTRING(255)
TheExt CSTRING(255)
BuildString STRING(50)
FullDirectoryName CSTRING(255)
!Function Code:
MEMBER('programs.clw') ! This is a MEMBER module
MakePath FUNCTION (FullFileName) ! Declare Procedure
CODE ! Begin processed code
z#=0
ThePath = FullFileName
If Fn_Split(ThePath,TheDrive,TheDir,TheName,TheExt).
clear(FullDirectoryName)
loop i#=1 to len(clip(TheDir))
If TheDir[i#]='\'
BuildString=clip(BuildString)&'\'
FullDirectoryName = left(BuildString)
clear(FullDirectoryName[len(clip(FullDirectoryName))])
If FullDirectoryName
FullDirectoryName = TheDrive&FullDirectoryName
Z#+=MkDir(FullDirectoryName)
end
else
BuildString[i#]=TheDir[i#]
end
end
If z#<0 then return(0) else return(1).
Today is November 21, 2024, 8:14 am This article has been viewed 35220 times.
|
|