FS_ReadDirectoryChanges_Create¶
FS_ReadDirectoryChanges_Create startet die Beobachtung eines Verzeichnisses. Die Änderungen (Dateien zufügen, löschen, umbenennen) werden protokolliert und können mit der Funktion FS_ReadDirectoryChanges_Get abgerufen werden.
-
dc = FS_ReadDirectoryChanges_Create(ssDir)
-
dc = FS_ReadDirectoryChanges_Create(ssDir, svFileFilter)
-
dc = FS_ReadDirectoryChanges_Create(ssDir, svFileFilter, nNotify)
-
dc = FS_ReadDirectoryChanges_Create(ssDir, svFileFilter, nNotify, bWatchSubtree)
-
dc = FS_ReadDirectoryChanges_Create(ssDir, svFileFilter, nNotify, bWatchSubtree, bIncludeFilter)
Returnwert
dc ist ein Objekt vom Typ DIRWATCHITEM oder 0, falls ein Fehler aufgetreten ist.
Parameter
-
ssDir
ssDir ist das Verzeichnis, das beobachtet werden soll.
-
svFilter
Ist ein String-Vektor mit Dateifiltern, siehe Beispiel. Default Filter ist „*.*“.
-
nNotify
nNotify ist eine ODER-Verknüpfung der folgenden Werte sein:
Wert Bedeutung FILE_NOTIFY_CHANGE_FILE_NAME Any file name change in the watched directory or subtree causes a change notification wait operation to return. Changes include renaming, creating, or deleting a file. FILE_NOTIFY_CHANGE_DIR_NAME Any directory-name change in the watched directory or subtree causes a change notification wait operation to return. Changes include creating or deleting a directory. FILE_NOTIFY_CHANGE_ATTRIBUTES Any attribute change in the watched directory or subtree causes a change notification wait operation to return. FILE_NOTIFY_CHANGE_SIZE Any file-size change in the watched directory or subtree causes a change notification wait operation to return. The operating system detects a change in file size only when the file is written to the disk. For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed. FILE_NOTIFY_CHANGE_LAST_WRITE Any change to the last write-time of files in the watched directory or subtree causes a change notification wait operation to return. The operating system detects a change to the last write-time only when the file is written to the disk. For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed. FILE_NOTIFY_CHANGE_LAST_ACCESS Any change to the last access time of files in the watched directory or subtree causes a change notification wait operation to return. FILE_NOTIFY_CHANGE_CREATION Any change to the creation time of files in the watched directory or subtree causes a change notification wait operation to return. FILE_NOTIFY_CHANGE_SECURITY Any security-descriptor change in the watched directory or subtree causes a change notification wait operation to return. Defaultwert ist FILE_NOTIFY_CHANGE_FILE_NAME.
-
bWatchSubtree
Falls der Parameter TRUE (1) ist, beobachtet die Funktion auch alle Unterverzeichnisse. Falls der Parameter FALSE (0) ist, wird nur das angegebene Verzeichnis beobachtet Defaultwert ist TRUE (1).
-
bIncludeFilter
Falls der Wert TRUE ist wird der Parameter svFileFilter als Include-Filter verwendet. Falls der Wert FALSE ist wird der Parameter svFileFilter als Exclude-Filter verwendet. Defaultwert ist TRUE (1).
Beispiel
def MonitorDirectory()
{
global __g__dwi;
AppKillTimer();
ssDir = "d:/test/";
if (__g__dwi == 0) {
__g__dwi = FS_ReadDirectoryChanges_Create(ssDir, ["*.utx", "*.nc"]);
if (__g__dwi == 0) {
MessageBoxError("Cannot watch directory: %s", ssDir);
return FALSE;
}
}
smFiles = FS_ReadDirectoryChanges_Get(__g__dwi);
if (smFiles[1] != "") {
idx = find(smFiles[;2] == "a"); // only added
svFiles = ssDir + smFiles[idx;1];
//
// do something with the files.
//
}
AppSetTimer(MonitorDirectory, 60*1000);
return TRUE;
}
MonitorDirectory()
History
Version | Beschreibung |
---|---|
5.5.0 | Neu. |
Siehe auch
id-826916