Hi Folks,
I need to create a directory where some intermediate directory(ies) may not exist. Does LiveCode have anything equivalent to the unix mkidr -p command, or will I have to check this manually? I figure I can split on slash and then loop through creating directories if they don't exist, but just wanted to check if I am missing something. I have searched through the documentation with out any luck.
Any help would be much appreciated.
Thanks,
Daryl
Create a directory along with intermediate directories
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Create a directory along with intermediate directories
Code: Select all
--
-- stdEnsurePath
--
-- Checks the path specified in pPath to make sure each of its
-- directories exists, creating any that need to be as it goes.
--
on stdEnsurePath pPath
set the itemdel to "/"
--
put item 1 of pPath into tTestPath
put pPath into tDestFolders
delete item 1 of tDestFolders
repeat for each item tFolder in tDestFolders
put "/"&tFolder after tTestPath
if there is not a folder tTestPath then
create folder tTestPath
Err the result, "Couldn't create folder ""e&tTestPath"e
end if
end repeat
end stdEnsurePath
--
-- ERR
--
-- Simple method for checking and reporting errors to the user.
-- Most useful to call for those circumstances where you would
-- check the result and display it if it contains an error.
-- By default, it exits to top, but you can pass any value
-- in the optional third param to prevent this exit.
--
on Err pResultStr, pErrMessage, pNoExitFlag
if pResultStr is not empty then
if pErrMessage is empty then answer pResultStr
else answer pErrMessage
if "appProgress" is in the windows then
close stack "appProgress"
end if
if pNoExitflag is empty then exit to top
end if
end Err
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Create a directory along with intermediate directories
Thanks FourthWorld, Much appreciated.
Regards,
Daryl
Regards,
Daryl