[EMAIL PROTECTED] writes:
>5. Delete folder should delete the folder and all of its contents. Right
>it will not delete if something is inside the folder.
maybe this functions & handlers solve your problem
for instance
get doOSUtility("Delete Directory and Contents", lDirectoryListToRemove)
(still working on this functions, but they seem to work quite well now)
(*** there is a bug in MC / Rev (Mac OS only) which should be solved in the
next MC release : if the pathname length is too long the getXFolder handler can
crash. So put the folder to examine, to delete, � not tooo deeep in your
system on Mac OS)
greetings from Belgium
Jan
$$$$$$$$$$$$$$$$$$$$$
function doOSUtility pOption, pData -- pData list of files, directories, �
set the itemdelimiter to "/"
if pOption = "Create Directory" then
repeat for each line lDir in pData
repeat with xx = 2 to the number of items of lDir
if item xx of lDir <> "" then
put (item 1 to xx of lDir) into lCurDir
if there is not a folder lCurDir then
create folder lCurDir
CheckSysError "DoOSUtility : error in '"&pOption&"' :"
end if
end if
end repeat
end repeat
else if pOption = "Rename File" then
if the paramCount <> 3 then StopWithMessage "doOSUtility : option
'"&pOption&"' needs 3 arguments !!"
put the param of 3 into lNewFileNames
put 0 into xx
repeat for each line lFile in pData
add 1 to xx
rename file lFile to (line xx of lNewFileNames)
CheckSysError "DoOSUtility : error in '"&pOption&"' :"
end repeat
else if pOption = "Delete File" then
repeat for each line lFile in pData
delete file lFile
CheckSysError "DoOSUtility : error in '"&pOption&"' :"
end repeat
else if pOption = "Delete Directory" then
repeat for each line lDir in pData
delete directory lDir
CheckSysError "DoOSUtility : error in '"&pOption&"' :"
end repeat
else if pOption = "Delete Contents" then
repeat for each line lDir in pData
DeleteDirAndContents lDir,false,"DoOSUtility : error in '"&pOption&"' :"
end repeat
else if pOption = "Delete Directory and Contents" then
repeat for each line lDir in pData
DeleteDirAndContents lDir,true,"DoOSUtility : error in '"&pOption&"' :"
delete directory lDir
CheckSysError "DoOSUtility : error in '"&pOption&"' :"
end repeat
end if
return ""
end doOSUtility
on DeleteDirAndContents pDir, pAlsoFolders, pMess
if pAlsoFolders then
global MyXFCNResult -- compatiblity with my old HC external
put getFolder(pDir,true,false,"","all","1"&CR&"2") into lContents
put MyXFCNResult into lObjectkind
put 0 into xx
else
put getFolder(pDir,true,false,"","files") into lContents
end if
repeat for each line lObject in lContents
if pAlsoFolders then
add 1 to xx
if line xx of lObjectkind = "2" then
DeleteDirAndContents lObject, true, pMess
delete directory lObject
else
delete file lObject
end if
else
delete file lObject
end if
CheckSysError pMess
end repeat
end DeleteDirAndContents
function getFolder pFolder, pReturnFullPathNames, pSeeSubFolders, pCreators,
pKind, tFileAndFolderChar
global MyXFCNResult
if pFolder = "" then
answer folder "Select a folder:"
if it = "" then return ""
if pKind = "Selected Folder" then
return(it)
end if
else get pFolder
if pReturnFullPathNames = "" then put true into pReturnFullPathNames
if pSeeSubFolders = "" then put false into pSeeSubFolders
if pCreators <> "" then StopWithMessage "GetFolder MUST have an empty fourth
argument !"&return&"(WAS earlier filetypes)"
if pSeeSubFolders and not(pReturnFullPathNames) then StopWithMessage
"GetFolder MUST return fullpath names (2nd arg. true) when it has to look in
subfolders (3nd arg. true))"
if pKind = "" then put "Files" into pKind
if tFileAndFolderChar <> "" then put (char 1 of line 1 of
tFileAndFolderChar)&CR&(char 1 of line 2 of tFileAndFolderChar) into
tFileAndFolderChar
put "" into MyXFCNResult
return(getXFolder(it, pReturnFullPathNames, pSeeSubFolders, pCreators, pKind,
tFileAndFolderChar))
end getFolder
function getXFolder pFolder, pReturnFullPathNames, pSeeSubFolders, pCreators,
pKind, tFileAndFolderChar
global MyXFCNResult
if there is a folder pFolder then
put the defaultfolder into tSavedDefFolder
set the defaultfolder to pFolder
put the files & CR & (line 2 to -1 of the folders) into litems
sort litems
if last char of pFolder <> "/" then put "/" after pFolder
repeat for each line lLine in litems
if lLine <> "" then
put pFolder&lLine into lCurItem
put (there is a folder lCurItem) into curItemIsFolder
if pKind = "All" or (pKind = "Files" and not(curItemIsFolder)) or
(pKind = "Folders" and curItemIsFolder) then
if not(pReturnFullPathNames) then
put CR&lLine after lResult
else
put CR&(lCurItem) after lResult
if curItemIsFolder then put "/" after lResult
end if
if tFileAndFolderChar <> "" then
if curItemIsFolder then get 2
else get 1
put CR&(line it of tFileAndFolderChar) after MyXFCNResult
end if
end if
if curItemIsFolder and pSeeSubFolders then
put CR&getXFolder(lCurItem, pReturnFullPathNames, true, pCreators,
pKind, tFileAndFolderChar) after lResult
end if
end if
if last char of lResult = CR then delete last char of lResult
if last char of MyXFCNResult = CR then delete last char of MyXFCNResult
end repeat
set the defaultfolder to tSavedDefFolder
end if
if char 1 of lResult = CR then delete char 1 of lResult
if char 1 of MyXFCNResult = CR then delete char 1 of MyXFCNResult
return(lResult)
end getXFolder
on StopWithMessage pMess
answer pMess
exit to top
end StopWithMessage
on CheckSysError pMess
put the SysError into lError
if lError is not zero then StopWithMessage pMess&&lError&&"!!"
end CheckSysError
_______________________________________________
improve-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/improve-revolution