home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 3.0 KB | 141 lines | [TEXT/ToyS] |
- -- Preferences
- property kasPrefName : "Trash Desktop DB 1.0"
- property kasDontDo : {"Trash", "Temporary Items", "Icon" & return, "VM Storage", "OpenFolderListDF" & return, "DesktopPrinters DB"}
-
- -- Globals
- global gasInfoWind -- Info window
- global gasInfoPos -- Position of info window
- global gasTrashed -- Number gone!
- global gasChecked -- Number checked!
-
-
- on run
- -- Load prefs, show window
- pfLoad()
-
- set gasTrashed to 0
- set gasChecked to 0
- set fsObjs to {}
-
- set gasInfoWind to display info titled kasPrefName ¬
- located at gasInfoPos ¬
- message "Scanning…"
-
- -- Get all root files/folders on writable volumes
- repeat with n from 1 to 256
- try
- set vInfo to the volume info of volume index n
- on error
- exit repeat
- end try
-
- -- Only writable volumes
- if not vol read only of vInfo then
- -- Get invisible items in root directory
- set rootFiles to the entries in (vol alias of vInfo) without whose visibility is
-
- repeat with rf in rootFiles
- if (rf is not in kasDontDo) then ¬
- set fsObjs to fsObjs & {(((vol alias of vInfo) as string) & rf) as alias}
- end repeat
- end if
- end repeat
-
- -- Do items
- repeat with fsObj in fsObjs
- DoOne(fsObj)
- end repeat
-
- display info gasInfoWind message "DONE!"
-
- pause for 5 with seconds timing -- Let screen wait...
-
- set gasInfoPos to screen location of ¬
- (display info gasInfoWind with disposal)
-
- pfSave() -- Save window location
-
- set choice to ¬
- display dialog ("Quit Finder to cause rebuild now?" & return & return & ¬
- "Answering No will cause the Desktop to be rebuilt when the computer is next started") ¬
- buttons {"No", "Yes"} default button 1
- if (button returned of choice is "Yes") then
- tell application "Finder" to quit
- pause for 5 with seconds timing
- ignoring application responses
- tell application "Finder" to run
- end ignoring
- end if
- end run
-
-
- on DoOne(fsObj)
- set aFileInfo to (alias info from fsObj)
-
- display info gasInfoWind ¬
- message "File: " & (original name of aFileInfo) ¬
- at line 2
-
- set gasChecked to gasChecked + 1
-
- try
- set myInfo to (extended info for fsObj)
- on error
- TrashFile(fsObj, "Info error.")
- return
- end try
-
- set invisible status of myInfo to false
-
- try
- set the catalog info of fsObj to myInfo
- on error
- beep
- end try
-
- TrashFile(fsObj, "Invisible")
-
- display info gasInfoWind ¬
- message ("Checked: " & gasChecked) ¬
- at line 7 ¬
- using color 15
- end DoOne
-
-
- on TrashFile(fsObj, reason)
- display info gasInfoWind ¬
- message reason at line 3
-
- try
- collate fsObj with the trasher
- on error err
- display info gasInfoWind ¬
- message ("Error: " & err) ¬
- at line 12 ¬
- using color (15 * 1024)
- beep
- end try
-
- set gasTrashed to gasTrashed + 1
-
- display info gasInfoWind ¬
- message ("Trashed: " & gasTrashed) ¬
- at line 8 ¬
- using color (15 * 1024)
- end TrashFile
-
-
- on pfLoad()
- try
- set ourPrefs to (load preference named kasPrefName)
- set gasInfoPos to item 1 of ourPrefs
- on error
- set gasInfoPos to {-1, -1}
- end try
- end pfLoad
-
-
- on pfSave()
- save preference {gasInfoPos} named kasPrefName
- end pfSave
-