home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 19 / AACD19.BIN / CDTools / S / UpdateIndices < prev    next >
Text File  |  2000-11-08  |  3KB  |  108 lines

  1. /*
  2.     Update local index files
  3.     $VER: UpdateIndices 1.1 (8.11.2000)
  4.     by Neil Bothwick
  5.  
  6.     1.1  - Uses "parse source" to get the name of the CD
  7. */
  8.  
  9. /* ;;; Initialise */
  10. options results
  11. address command
  12. signal on error
  13. call LoadLib('rexxsupport.library')
  14. call LoadLib('rexxdossupport.library')
  15.  
  16. parse source . ' ' . ' ' . ' ' ScriptName ' ' .
  17. CDName = left(ScriptName, pos(':', ScriptName) - 1)
  18. ;;;
  19. /* ;;; Ask whether the user wishes to update */
  20. if pos('AUTUP=Automatic',GetVar('AACD.prefs',Global,Binary)) = 0 then do
  21.     if length(GetVar('AACDIndex')||GetVar('AminetCDIndex')||GetVar('AminetSetIndex')||GetVar('AminetIndex')) = 0 then exit
  22.     'RequestChoice >ENV:AAUpdateNow "Amiga Active CD" "Do you wish to update the CD index*Nfiles on your hard drive with the new*Nones from the CD?" "Yes|No"'
  23.     if GetVar('AAUpdateNow') = 0 then do
  24.         call ShowMsg('This requester should not appear again.*NYou may update the index files at any time*Nfrom the Search section of AACDprefs')
  25.         call delete('ENV:AAUpdateNow')
  26.         exit
  27.         end
  28.     call delete('ENV:AAUpdateNow')
  29.     end
  30. ;;;
  31. /* ;;; Update Index files */
  32. /* AACD indices */
  33. DestDir = GetVar('AACDIndex')
  34. SrcDir = CDName':CDTools/Indices'
  35. Pattern = ParsePattern('AACD??',NOCASE)
  36. if DestDir > '' then call CopyFiles()
  37.  
  38. /* Aminet CD indices */
  39. DestDir = GetVar('AminetCDIndex')
  40. SrcDir = CDName':AACD/CDROM/AminetCDs/CDs'
  41. Pattern = ParsePattern('Index??',NOCASE)
  42. if DestDir > '' then call CopyFiles()
  43.  
  44. /* Aminet Set indices */
  45. DestDir = GetVar('AminetSetIndex')
  46. SrcDir = CDName':AACD/CDROM/AminetCDs/Sets'
  47. Pattern = ParsePattern('Set?',NOCASE)
  48. if DestDir > '' then call CopyFiles()
  49.  
  50. /* Aminet Online indices */
  51. DestDir = GetVar('AminetIndex')
  52. if DestDir > '' then do
  53.     SrcDir = CDName':AACD/Online/Aminet'
  54.     call DateCopy('INDEX')
  55.     call DateCopy('dirlist')
  56.     call open(List,AddPart(SrcDir,'dirlist'),'R')
  57.     do until eof(List)
  58.         File = readln(List)
  59.         if File = '' then iterate
  60.         call DateCopy(File)
  61.         end
  62.     call close(List)
  63.     end
  64. ;;;
  65. /* ;;; Exit */
  66. if Updated = 1 then call ShowMsg('All index files are up to date')
  67. exit
  68. ;;;
  69. /* ;;; Copy new files */
  70. CopyFiles:
  71.     FileList = showdir(SrcDir)
  72.     do i = 1 to words(FileList)
  73.         if MatchPattern(Pattern,word(FileList,i),NOCASE,PARSED) then call DateCopy(word(FileList,i))
  74.         end
  75.     return
  76. ;;;
  77. /* ;;; Copy updated files */
  78. DateCopy:
  79.     parse arg FileName
  80.     say fileName '-' DestDir
  81.     if word(statef(AddPart(SrcDir,FileName)),5) > word(statef(AddPart(DestDir,FileName)),5) then do
  82.         address command 'Copy >NIL:' AddPart(SrcDir,FileName) DestDir 'CLONE'
  83.         Updated = 1
  84.         end
  85.     return
  86. ;;;
  87. /* ;;; Load a library */
  88. LoadLib:
  89.     parse arg library
  90.     if show('L',library) then return
  91.     if ~exists('LIBS:'library) then address command 'copy System/Libs/'library 'LIBS: clone quiet'
  92.     if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
  93.     return
  94. ;;;
  95. /* ;;; ShowMsg */
  96. ShowMsg:
  97.     parse arg msg
  98.     address command 'RequestChoice >NIL: "Amiga Active CD" "'msg'" "OK"'
  99.     return
  100. ;;;
  101. /* ;;; Error handler */
  102. Error:
  103.     call ShowMsg('Error' RC 'in line' sigl)
  104.     if RC > 5 then exit
  105.     return
  106. ;;;
  107.  
  108.