home *** CD-ROM | disk | FTP | other *** search
- on AllScripts_______________________
- end
-
- on AskForSourceFolder
- global gMultiAll, gSourceFolder, gDestFolder, gTopFolder, gSourceFolderList, gSourceFileList
- if gMultiAll then
- GoMulti()
- else
- if (gSourceFolder <> EMPTY) and (OSIsDirectory(gSourceFolder) = 1) then
- dosSetCurrentFolder(ExtractParentFolder(gSourceFolder))
- end if
- set TempgSourceFolder to OSSelectFolder()
- if TempgSourceFolder = 0 then
- exit
- end if
- if TempgSourceFolder = gDestFolder then
- AlertBox("You cannot choose the same Folder two times.")
- exit
- end if
- set gTopFolder to TempgSourceFolder
- set gSourceFolder to TempgSourceFolder
- set gSourceFolderList to []
- set gSourceFileList to []
- put AccorciaNome(gSourceFolder) into field "fSourceFolder"
- put " " into field "fItems"
- FrecciaShortLog(0)
- CheckSyncButton()
- end if
- end
-
- on AskForDestFolder
- global gMultiAll, gSourceFolder, gDestFolder, gBottomFolder, gDestFolderList, gDestFileList
- if gMultiAll then
- GoMulti()
- else
- if (gDestFolder <> EMPTY) and (OSIsDirectory(gDestFolder) = 1) then
- dosSetCurrentFolder(ExtractParentFolder(gDestFolder))
- end if
- set TempgDestFolder to OSSelectFolder()
- if TempgDestFolder = 0 then
- exit
- end if
- if TempgDestFolder = gSourceFolder then
- AlertBox("You cannot choose the same Folder two times.")
- exit
- end if
- set gBottomFolder to TempgDestFolder
- set gDestFolder to TempgDestFolder
- set gDestFolderList to []
- set gDestFileList to []
- put AccorciaNome(gDestFolder) into field "fDestFolder"
- put " " into field "fItems"
- FrecciaShortLog(0)
- CheckSyncButton()
- end if
- end
-
- on GetSourceFolder
- global gFolderList, gFileList, gSourceFolder, gSourceFolderList, gSourceFileList
- set gFolderList to []
- set gFileList to []
- ScanFolders(gSourceFolder)
- deleteAt(gFolderList, 1)
- set gSourceFolderList to gFolderList
- set gSourceFileList to gFileList
- set gFolderList to []
- set gFileList to []
- end
-
- on GetDestFolder
- global gFolderList, gFileList, gDestFolder, gDestFolderList, gDestFileList
- set gFolderList to []
- set gFileList to []
- ScanFolders(gDestFolder)
- deleteAt(gFolderList, 1)
- set gDestFolderList to gFolderList
- set gDestFileList to gFileList
- set gFolderList to []
- set gFileList to []
- end
-
- on ScanFolders myFolder
- global gFolderList, gInvisible, gRegisteredCopy, gNumTotFiles, gMaxUnreg, gFilterAll, gFilterScript, gPrBarIter
- append(gFolderList, myFolder)
- set listaItems to OSGetFileNamesinFolder(myFolder, gInvisible)
- if listaItems = EMPTY then
- exit
- end if
- set totItems to the number of lines in listaItems
- repeat with i = 1 to totItems
- if the mouseDown and (the rollOver = 13) and (field "P4" = "Stop") then
- pass()
- end if
- set myItem to myFolder & line i of listaItems
- if myItem = myFolder then
- set myItem to myFolder & line i - 1 of listaItems & RETURN
- end if
- if OSIsDirectory(myItem) = 1 then
- ScanFolders(myItem)
- else
- if OSIsDirectory(myItem) = 0 then
- if (gRegisteredCopy = 0) and (gNumTotFiles >= gMaxUnreg) then
- StoppaUnregistered()
- end if
- if gFilterAll and (gFilterScript <> EMPTY) then
- if FilterThis(myItem) then
- set gNumTotFiles to gNumTotFiles + 1
- append(gFileList, myItem)
- put "Files Found:" && gNumTotFiles into field "fItems"
- end if
- else
- set gNumTotFiles to gNumTotFiles + 1
- append(gFileList, myItem)
- put "Files Found:" && gNumTotFiles into field "fItems"
- end if
- end if
- end if
- set gPrBarIter to gPrBarIter + 1
- set the locH of sprite 2 to 147 + (gPrBarIter mod 16)
- updateStage()
- end repeat
- end
-
- on AskSyncronizza
- global gOneDirection, gMultiAll, gSourceFolder, gDestFolder, gAskConfirm
- if NoSelectedFolders() then
- exit
- end if
- if gOneDirection then
- set theTask to "BackUp"
- else
- set theTask to "Synchronize"
- end if
- if not gAskConfirm then
- if gMultiAll then
- DoMultiSynchronize()
- else
- DoSingleSynchronize()
- end if
- else
- if gMultiAll then
- DialogBoxSiNo("Would you " & theTask & " from Multiple List?", "DoMultiSynchronize", "nothing")
- else
- DialogBoxSiNo("Would you " & theTask & " folder" && QUOTE & ExtractFileNameFromPath(gSourceFolder) & QUOTE && "with" && QUOTE & ExtractFileNameFromPath(gDestFolder) & QUOTE & "?", "DoSingleSynchronize", "nothing")
- end if
- end if
- end
-
- on DoSynchronize
- global gMultiAll
- if gMultiAll then
- set err to DoMultiSynchronize()
- else
- set err to DoSingleSynchronize()
- end if
- return err
- end
-
- on DoSingleSynchronize
- PreSynchronizing()
- set err to DoOneSynchronize()
- FineSingleSync()
- return err
- end
-
- on PreSynchronizing
- global gTimerAll, gStopTimerAll, gFilterAll, gIterMulti, gShortReportList, gLogPathList
- updateStage()
- set gIterMulti to 0
- set gStopTimerAll to gTimerAll
- set gTimerAll to 0
- set gShortReportList to []
- set gLogPathList to []
- if gFilterAll then
- CompactFilters()
- end if
- end
-
- on FineSingleSync
- global gOneDirection, gSourceFolder, gDestFolder, gAFilesCopied, gAFilesReplaced, gBFilesCopied, gBFilesReplaced, gTimerAll, gStopTimerAll, gBeepWhenDone, gLastBackUpDate
- put " " into field "fItems"
- put MyOperationBtn() into field "P4"
- put " " into field "fItems"
- set mySourceName to AccorciaNome(gSourceFolder, 35)
- set myDestName to AccorciaNome(gDestFolder, 35)
- set bfiles to string(gBFilesCopied + gBFilesReplaced)
- set afiles to string(gAFilesCopied + gAFilesReplaced)
- put "Files copied into:" & RETURN into field "fItems"
- if gOneDirection <> 1 then
- put "•" && mySourceName & ":" && afiles & RETURN after field "fItems"
- end if
- put "•" && myDestName & ":" && bfiles & RETURN after field "fItems"
- FrecciaShortLog(1)
- set gLastBackUpDate to [TodayYear(1), TodayMonth(1), TodayDay(1)]
- cursor(-1)
- set gTimerAll to gStopTimerAll
- beep(gBeepWhenDone)
- return 0
- end
-
- on DoOneSynchronize
- global gSourceFolderList, gSourceFileList, gDestFolderList, gDestFileList, gShortTextLog, gShortReportList, gBigTextLog, gSaveLogFile
- updateStage()
- SetHeaderLogFile()
- set err to NoValidFolders()
- if err then
- return err
- end if
- FrecciaShortLog(0)
- cursor(4)
- AzzeraCounters()
- ShowProgressBar()
- GetSourceFolder()
- GetDestFolder()
- EraseDestItems()
- HideInfiniteProgressBar()
- CoreSynch()
- PurgeAftertask()
- return 0
- end
-
- on PurgeAftertask
- global gSourceFolderList, gSourceFileList, gDestFolderList, gDestFileList, gShortTextLog, gShortReportList, gBigTextLog, gSaveLogFile
- HideInfiniteProgressBar()
- HideProgressBar()
- set TextReport to SetFooterLogFile()
- set gSourceFolderList to []
- set gSourceFileList to []
- set gDestFolderList to []
- set gDestFileList to []
- put TextReport after gShortTextLog
- append(gShortReportList, gShortTextLog)
- put "--" & RETURN after gBigTextLog
- put TextReport after gBigTextLog
- if gSaveLogFile then
- SaveLogFile()
- end if
- set gBigTextLog to EMPTY
- end
-
- on AbortSync message
- global gScambioFolders, gOneDirection, gSaveLogFile, gMultiAll, gTimerAll, gStopTimerAll, gShortReportList, gShortTextLog, gBigTextLog, gDoAndQuit, gJustLaunched
- if message starts "User pressed" then
- set byUser to 1
- else
- set byUser to 0
- end if
- if not voidp(message) and (message <> EMPTY) then
- put message & RETURN after gBigTextLog
- put message & RETURN after gShortTextLog
- end if
- if gScambioFolders = 1 then
- ScambiaCartelle()
- end if
- put " " into field "fItems"
- put MyOperationBtn() into field "P4"
- PurgeAftertask()
- if not byUser then
- set gStopTimerAll to 0
- SpegniTimer()
- end if
- if gMultiAll then
- FineMultiSync()
- else
- FineSingleSync()
- end if
- if gDoAndQuit and gJustLaunched then
- quit()
- else
- abort()
- end if
- end
-
- on CoreSynch
- global gBigTextLog, gScambioFolders, gOneDirection, gAFoldersCreated, gAFilesRenamed, gAFilesCopied, gAFilesReplaced, gBFoldersCreated, gBFilesRenamed, gBFilesCopied, gBFilesReplaced, gTotFoldCreated, gTotFileRenamed, gTotFileCopied, gTotFileReplaced
- set gScambioFolders to 0
- repeat with mySwap = 1 to 2
- put "--" & RETURN after gBigTextLog
- SyncFolders()
- if gScambioFolders = 0 then
- set gBFilesRenamed to gTotFileRenamed
- else
- set gAFilesRenamed to gAFilesRenamed + gTotFileRenamed
- end if
- set gTotFileRenamed to 0
- SyncFiles()
- if gScambioFolders = 0 then
- set gAFilesRenamed to gTotFileRenamed
- set gBFoldersCreated to gTotFoldCreated
- set gBFilesCopied to gTotFileCopied
- set gBFilesReplaced to gTotFileReplaced
- else
- set gBFilesRenamed to gBFilesRenamed + gTotFileRenamed
- set gAFoldersCreated to gTotFoldCreated
- set gAFilesCopied to gTotFileCopied
- set gAFilesReplaced to gTotFileReplaced
- end if
- set gTotFoldCreated to 0
- set gTotFileRenamed to 0
- set gTotFileCopied to 0
- set gTotFileReplaced to 0
- if gOneDirection = 1 then
- exit repeat
- end if
- ScambiaCartelle()
- set gScambioFolders to gScambioFolders + 1
- end repeat
- end
-
- on FrecciaShortLog myFlag
- if myFlag then
- set the locV of sprite 18 to 135
- else
- set the locV of sprite 18 to -1000
- end if
- updateStage()
- end
-
- on AzzeraCounters
- global gSourceFolderList, gSourceFileList, gDestFolderList, gDestFileList, gNumTotFiles, gPrBarIter, gTotError, gScambioFolders, gTotFoldCreated, gTotFileRenamed, gTotFileCopied, gTotFileReplaced, gAFoldersCreated, gAFilesRenamed, gAFilesCopied, gAFilesReplaced, gBFoldersCreated, gBFilesRenamed, gBFilesCopied, gBFilesReplaced
- set gSourceFolderList to []
- set gSourceFileList to []
- set gDestFolderList to []
- set gDestFileList to []
- set gNumTotFiles to 0
- set gPrBarIter to 0
- set gTotError to 0
- set gScambioFolders to 0
- set gTotFoldCreated to 0
- set gTotFileRenamed to 0
- set gTotFileCopied to 0
- set gTotFileReplaced to 0
- set gAFoldersCreated to 0
- set gAFilesRenamed to 0
- set gAFilesCopied to 0
- set gAFilesReplaced to 0
- set gBFoldersCreated to 0
- set gBFilesRenamed to 0
- set gBFilesCopied to 0
- set gBFilesReplaced to 0
- end
-
- on EraseDestItems
- global gOneDirection, gDestructive, gBigTextLog, gSep, gPrBarIter, gTotErasedFiles, gDestFileList, gSourceFileList, gUnlockFile, gTotErasedFolders, gDestFolderList, gSourceFolderList, gOnErrorDo, gTotError
- if (gOneDirection = 0) or (gDestructive = 0) then
- exit
- end if
- put "--" & RETURN after gBigTextLog
- put "Scan to delete items..." into field "fItems"
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to gSep
- set gTotErasedFiles to 0
- repeat with myFile in gDestFileList
- if the mouseDown and (the rollOver = 13) and (field "P4" = "Stop") then
- pass()
- end if
- if getPos(gSourceFileList, DestToSourceFolder(myFile)) = 0 then
- set fileIsLocked to dosGetFileAttribute(myFile, "Read Only")
- if gUnlockFile and fileIsLocked then
- OSSetFileLock(myFile, 0)
- end if
- set err to OSDelete(myFile)
- if err then
- if fileIsLocked then
- set myLock to " locked"
- else
- set myLock to EMPTY
- end if
- case gOnErrorDo of
- 0:
- set the itemDelimiter to oldDelimiter
- set message to "Cannot delete the" & myLock & " file" && QUOTE & AccorciaNome(myFile, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot delete the" & myLock & " file:" & RETURN & myFile & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- else
- set gTotErasedFiles to gTotErasedFiles + 1
- put "Files Deleted:" && gTotErasedFiles into field "fItems"
- put "Deleted File:" & RETURN & myFile & RETURN after gBigTextLog
- end if
- end if
- set gPrBarIter to gPrBarIter + 1
- set the locH of sprite 2 to 147 + (gPrBarIter mod 16)
- updateStage()
- end repeat
- set gTotErasedFolders to 0
- set MaxFolders to count(gDestFolderList)
- repeat with k = 0 to MaxFolders - 1
- if the mouseDown and (the rollOver = 13) and (field "P4" = "Stop") then
- pass()
- end if
- set i to MaxFolders - k
- set myFolder to getAt(gDestFolderList, i)
- if getPos(gSourceFolderList, DestToSourceFolder(myFolder)) = 0 then
- set ok to dosDeleteFolder(myFolder)
- if ok = 0 then
- set the itemDelimiter to oldDelimiter
- set message to "Cannot delete the folder" && QUOTE & AccorciaNome(myFolder, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- end if
- set gTotErasedFolders to gTotErasedFolders + 1
- put "Folders Deleted:" && gTotErasedFolders into field "fItems"
- put "Deleted Folder:" & RETURN & myFolder & RETURN after gBigTextLog
- end if
- set gPrBarIter to gPrBarIter + 1
- set the locH of sprite 2 to 147 + (gPrBarIter mod 16)
- updateStage()
- end repeat
- set the itemDelimiter to oldDelimiter
- end
-
- on ScambiaCartelle
- global gSourceFolderList, gDestFolderList, gSourceFileList, gDestFileList, gSourceFolder, gDestFolder
- set TgSourceFolderList to gSourceFolderList
- set gSourceFolderList to gDestFolderList
- set gDestFolderList to TgSourceFolderList
- set TgSourceFileList to gSourceFileList
- set gSourceFileList to gDestFileList
- set gDestFileList to TgSourceFileList
- set TgSourceFolder to gSourceFolder
- set gSourceFolder to gDestFolder
- set gDestFolder to TgSourceFolder
- end
-
- on SyncFolders
- global gSep, gSourceFolder, gDestFolder, gSourceFolderList, gDestFileList, gUnlockFile, gOnErrorDo, gTotFileRenamed, gTotFoldCreated, gTotError, gBigTextLog
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to gSep
- set s to the number of items in gSourceFolder - 1
- set SemiDestFold to item 1 to the number of items in gDestFolder - 1 of gDestFolder
- set mySourceFolderName to ExtractFileNameFromPath(gSourceFolder)
- set myDestFolderName to ExtractFileNameFromPath(gDestFolder)
- set Predict to "Folders from" && QUOTE & mySourceFolderName & QUOTE && "to" && QUOTE & myDestFolderName & QUOTE & ":"
- set sourceFolderCount to count(gSourceFolderList)
- if sourceFolderCount = 0 then
- exit
- end if
- set blockSourceFolderCount to sourceFolderCount
- set H to (the width of member "myProgBack" - 3) / float(sourceFolderCount)
- put " " into field "fItems"
- set the loc of sprite 3 to point(48, 150)
- set the loc of sprite 4 to point(-71, 150)
- updateStage()
- repeat with j = 1 to count(gSourceFolderList)
- set sourceFold to getAt(gSourceFolderList, j)
- if the mouseDown and (the rollOver = 13) and (field "P4" = "Stop") then
- pass()
- end if
- set destFold to sourceFold
- put SemiDestFold into item 1 to s of destFold
- if OSIsDirectory(destFold) = 0 then
- set OldFile to destFold
- delete char -30000 of OldFile
- set newPathName to GetUniquePathNameInFolder(OldFile)
- set NewName to ExtractFileNameFromPath(newPathName)
- set modifLock to 0
- set fileIsLocked to dosGetFileAttribute(OldFile, "Read Only")
- if gUnlockFile and fileIsLocked then
- OSSetFileLock(OldFile, 0)
- set modifLock to 1
- end if
- set err to OSRename(OldFile, NewName)
- if err then
- if fileIsLocked then
- set myLock to " locked"
- else
- set myLock to EMPTY
- end if
- case gOnErrorDo of
- 0:
- set message to "Error renaming the" & myLock & " file" && QUOTE & AccorciaNome(OldFile, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot rename the" & myLock & " file:" & RETURN & OldFile && "with new name" & RETURN & newPathName & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- else
- set gTotFileRenamed to gTotFileRenamed + 1
- put "Renamed File:" & RETURN & OldFile && "with new name" & RETURN & newPathName & RETURN after gBigTextLog
- setAt(gDestFileList, getPos(gDestFileList, OldFile), newPathName)
- end if
- if modifLock = 1 then
- OSSetFileLock(newPathName, 1)
- end if
- end if
- if OSIsDirectory(destFold) <> 1 then
- OSCreateDir(ExtractParentFolder(destFold), ExtractFileNameFromPath(destFold))
- set err to OSIsDirectory(destFold) <> 1
- if err = 0 then
- set gTotFoldCreated to gTotFoldCreated + 1
- put "Created Dir:" & RETURN & destFold & RETURN after gBigTextLog
- set comm to OSGetComment(sourceFold)
- if stringp(comm) then
- OSSetComment(destFold, comm)
- end if
- else
- case gOnErrorDo of
- 0:
- set message to "Error creating folder" && QUOTE & AccorciaNome(destFold, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot create the folder:" & RETURN & destFold & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- end if
- end if
- set sourceFolderCount to sourceFolderCount - 1
- put Predict && sourceFolderCount into field "fItems"
- set the locH of sprite 4 to -71 + (H * (blockSourceFolderCount - sourceFolderCount))
- if (H * (blockSourceFolderCount - sourceFolderCount)) < 8 then
- set the locH of sprite 3 to 48 + (H * (blockSourceFolderCount - sourceFolderCount))
- end if
- updateStage()
- end repeat
- set the itemDelimiter to oldDelimiter
- end
-
- on SyncFiles
- global gSep, gSourceFolder, gDestFolder, gSourceFileList, gTotFileCopied, gUnlockFile, gTotFileRenamed, gOnErrorDo, gTotError, gBigTextLog
- set oldDelimiter to the itemDelimiter
- set the itemDelimiter to gSep
- set s to the number of items in gSourceFolder - 1
- set SemiDestFold to item 1 to the number of items in gDestFolder - 1 of gDestFolder
- set mySourceFolderName to ExtractFileNameFromPath(gSourceFolder)
- set myDestFolderName to ExtractFileNameFromPath(gDestFolder)
- set Predict to "Files from" && QUOTE & mySourceFolderName & QUOTE && "to" && QUOTE & myDestFolderName & QUOTE & ":"
- set sourceFileCount to count(gSourceFileList)
- if sourceFileCount = 0 then
- exit
- end if
- set blockSourceFileCount to sourceFileCount
- set H to (the width of member "myProgBack" - 3) / float(sourceFileCount)
- put " " into field "fItems"
- set the loc of sprite 3 to point(48, 150)
- set the loc of sprite 4 to point(-71, 150)
- updateStage()
- repeat with sourceFile in gSourceFileList
- if the mouseDown and (the rollOver = 13) and (field "P4" = "Stop") then
- pass()
- end if
- set destFile to sourceFile
- put SemiDestFold into item 1 to s of destFile
- if OSIsDirectory(destFile) = 0 then
- if ConfrontaRecenteFile(sourceFile, destFile) = 1 then
- RimpiazzaFile(sourceFile, destFile)
- end if
- else
- if OSIsDirectory(destFile) < 0 then
- set err to OSFileCopy(sourceFile, destFile)
- if err then
- case gOnErrorDo of
- 0:
- set message to "Error copying file" && QUOTE & AccorciaNome(sourceFile, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot copy the file from:" & RETURN & sourceFile && "to:" & RETURN & destFile & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- else
- set gTotFileCopied to gTotFileCopied + 1
- put "Copied File from:" & RETURN & sourceFile && "into" & RETURN & destFile & RETURN after gBigTextLog
- end if
- else
- if OSIsDirectory(destFile) = 1 then
- set parID to ExtractParentFolder(sourceFile)
- set fileName to ExtractFileNameFromPath(sourceFile)
- set newPathName to sourceFile
- set k to 0
- repeat while (OSIsDirectory(newPathName) >= 0) or (OSIsDirectory(SourceToDestFolder(newPathName)) >= 0)
- set k to k + 1
- set lun to 30 - length(string(k))
- set newPathName to parID & Sinistra(fileName, lun) & "." & string(k)
- end repeat
- set NewName to ExtractFileNameFromPath(newPathName)
- set modifLock to 0
- if gUnlockFile and (dosGetFileAttribute(sourceFile, "Read Only") = 1) then
- OSSetFileLock(sourceFile, 0)
- set modifLock to 1
- end if
- set err to OSRename(sourceFile, NewName)
- if err then
- case gOnErrorDo of
- 0:
- set message to "Error renaming file" && QUOTE & AccorciaNome(sourceFile, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot rename the file:" & RETURN & sourceFile && "with new name" & RETURN & newPathName & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- else
- set gTotFileRenamed to gTotFileRenamed + 1
- put "Renamed File:" & RETURN & sourceFile && "with new name" & RETURN & newPathName & RETURN after gBigTextLog
- setAt(gSourceFileList, getPos(gSourceFileList, parID & fileName), newPathName)
- end if
- if modifLock = 1 then
- OSSetFileLock(newPathName, 1)
- end if
- set tempDest to ExtractParentFolder(destFile) & NewName
- set err to OSFileCopy(newPathName, tempDest)
- if err then
- case gOnErrorDo of
- 0:
- set message to "Error copying file" && QUOTE & AccorciaNome(newPathName, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot copy the file:" & RETURN & newPathName && "into" & RETURN & tempDest & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- else
- set gTotFileCopied to gTotFileCopied + 1
- put "Copied File:" & RETURN & newPathName && "into" & RETURN & tempDest & RETURN after gBigTextLog
- end if
- end if
- end if
- end if
- set sourceFileCount to sourceFileCount - 1
- put Predict && sourceFileCount into field "fItems"
- set the locH of sprite 4 to -71 + (H * (blockSourceFileCount - sourceFileCount))
- if (H * (blockSourceFileCount - sourceFileCount)) < 8 then
- set the locH of sprite 3 to 48 + (H * (blockSourceFileCount - sourceFileCount))
- end if
- updateStage()
- end repeat
- end
-
- on RimpiazzaFile sourceF, destF
- global gUnlockFile, gTotFileReplaced, gOnErrorDo, gTotError, gBigTextLog
- set myParID to ExtractParentFolder(destF)
- set TempFileName to "TempFileFoldersSynchronizer"
- set TempFile to myParID & TempFileName
- set destFileName to ExtractFileNameFromPath(destF)
- if OSIsDirectory(TempFile) = 0 then
- OSSetFileLock(TempFile, 0)
- set err to OSDelete(TempFile)
- if err then
- case gOnErrorDo of
- 0:
- set message to "Error deleting temp file" && QUOTE & AccorciaNome(TempFile, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot delete the Temp File:" & RETURN & TempFile & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- end if
- end if
- if (gUnlockFile = 0) and (dosGetFileAttribute(destF, "Read Only") = 1) then
- case gOnErrorDo of
- 0:
- set message to "Cannot replace the locked file" && QUOTE & AccorciaNome(destF, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot replace the locked file:" & RETURN & destF & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- exit
- end if
- set err to OSFileCopy(sourceF, TempFile)
- if err then
- if dosGetFileAttribute(sourceF, "Read Only") = 1 then
- set IsLockedSource to " locked"
- else
- set IsLockedSource to EMPTY
- end if
- case gOnErrorDo of
- 0:
- set message to "Error coping" & IsLockedSource & " file" && QUOTE & AccorciaNome(sourceF, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot copy the" & IsLockedSource & " file:" & RETURN & sourceF & " into:" & RETURN & TempFile & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- exit
- end if
- OSSetFileLock(TempFile, 0)
- set wasLocked to dosGetFileAttribute(destF, "Read Only")
- if gUnlockFile then
- OSSetFileLock(destF, 0)
- end if
- set err to OSDelete(destF)
- if err then
- OSDelete(TempFile)
- OSSetFileLock(destF, wasLocked)
- if wasLocked then
- set IsLockedDest to " locked"
- else
- set IsLockedDest to EMPTY
- end if
- case gOnErrorDo of
- 0:
- set message to "Error deleting" & IsLockedDest & " file" && QUOTE & AccorciaNome(destF, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot delete the" & IsLockedDest & " file:" & RETURN & destF & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- exit
- end if
- set err to OSRename(TempFile, destFileName)
- if dosGetFileAttribute(sourceF, "Read Only") = 1 then
- OSSetFileLock(destF, 1)
- end if
- if err then
- if dosGetFileAttribute(destF, "Read Only") = 1 then
- set IsLockedDest to " locked"
- else
- set IsLockedDest to EMPTY
- end if
- case gOnErrorDo of
- 0:
- set message to "Error renaming" & IsLockedDest & " file" && QUOTE & AccorciaNome(TempFile, 60) & QUOTE & "." & MsgTimer()
- AlertBox(message)
- AbortSync(message)
- 1:
- set gTotError to gTotError + 1
- put "¯ Error " & gTotError & ": Cannot rename the" & IsLockedDest & " Temp file:" & RETURN & TempFile & " to: " & destFileName & RETURN after gBigTextLog
- 2:
- nothing()
- end case
- else
- set gTotFileReplaced to gTotFileReplaced + 1
- put "Replaced old file:" & RETURN & destF && "with new file from" & RETURN & sourceF & RETURN after gBigTextLog
- end if
- end
-