Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any simple way to detect changes in a folder?
Message
 
À
15/06/2004 05:06:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00913782
Message ID:
00913787
Vues:
19
First thing that comes into my mind is to use ADIR(). Something like that:
FUNCTION DirectoryChange(path_to_dir)
   LOCAL is_changed
   LOCAL old_alias
   old_alias = ALIAS()
   IF .NOT. FILE(full_path_to_table + "DirChange.DBF") && Here You must create a table so
      CREATE DBF DirChange (F_NAME C(250), F_SIZE N(10), F_DATE D)
      INDEX ON UPPER(f_name) TAG DirChange
   ELSE
      SELECT 0
      USE DirChange ORDER DirChange EXCLUSIVE  && You must check If You can open that file exclusive
   ENDIF
   SELECT DirChange
   m1 = ADIR(aaaa,path_to_dir+"*.*")
   IF RECCOUNT("DirChange") # 0
      FOR f_loop = 1 TO m1
          SELECT DirChange
          SEEK UPPER(aaaa[f_loop,1])
          DO CASE
             CASE .NOT. FOUND() 
                  *** Directory changed. There is an additional file on it.
                  is_changed = .t. && You can use a numeric variable to know what exactly is changed
             CASE F_Size # aaaa[f_loop,2]
                  *** Directory changed. The size of some file has been changed
                  is_changed = .t.
             CASE F_Date # aaaa[f_loop,3]
                  *** Directory changed. The date of some file has been changed
                 is_changed = .t. 
          ENDCASE
      NEXT
   ENDIF
   SELECT DirChange
   ZAP
   INSERT INTO DirChange FROM ARRAY aaaa
   IF .NOT. EMPTY(old_alias)
      SELECT (old_alias)
   ENDIF

RETURN is_changed
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform