---
name: "KYSDK_FILEWATCHER_FileWatcher"
section: "3"
platform: "linux"
package: "libkysdk-system"
version: "3.0.1.4-1"
release: "Arch Linux 2026-11-07"
platforms: ["linux"]
url: "https://carta.tech/man/KYSDK_FILEWATCHER_FileWatcher"
---

# KYSDK\_FILEWATCHER\_FileWatcher(3)

File watcher class

## NAME

FileWatcher - File watcher class

## SYNOPSIS

```
#include <libkyfilewatcher.hpp>
```

## DESCRIPTION

The **FileWatcher** class is mainly used to add file paths that need to be monitored, add file lists that need to be monitored, remove specified files from the monitoring list, clear the monitoring list, pause file monitoring, and resume file monitoring.

This class belongs to the **KYSDK\_FILEWATCHER** namespace.

## MEMBER FUNCTIONS

**QStringList addWatchTargetRecursive (QString url, FileWatcherType type = PERIODIC, int attr = OPEN\|CLOSE\|MODIFY\|DELETE, int maxdepth = 5, int recurType = DIR\|REGULAR)**

Add a file path that needs to be monitored. For directories, recursive monitoring of subdirectories is enabled by default.

**Parameters:**

- **url**

  File path

- **type**

  File monitoring type

- **attr**

  File monitoring attributes

- **maxdepth**

  Specify the maximum depth for traversal search

- **recurType**

  Recursive type

**Return value:**

- **QStringList**

  List of successfully added monitoring target paths

**QStringList addWatchTargetListRecursive (QStringList urlList, FileWatcherType type = PERIODIC, int attr = OPEN\|CLOSE\|MODIFY\|DELETE, int maxdepth = 5, int recurType = DIR\|REGULAR)**

Add a list of files that need to be monitored.

**Parameters:**

- **urlList**

  List of files to be monitored

- **type**

  File monitoring type

- **attr**

  File monitoring attributes

- **maxdepth**

  Specify the maximum depth for traversal search

- **recurType**

  Recursive type

**Return value:**

- **QStringList**

  List of successfully added monitoring target paths

**QStringList removeWatchTargetRecursive (QString url, int maxdepth = 5, int recurType = ALLFILE)**

Remove the specified file from the monitoring list.

**Parameters:**

- **url**

  Path of the specified file

- **maxdepth**

  Specify the maximum depth for traversal search

- **recurType**

  Recursive type

**Return value:**

- **QStringList**

  List of successfully removed monitoring target paths

**void clearWatchList ()**

Clear the monitoring list.

**void pauseWatcher ()**

Pause file monitoring.

**void restartWatcher ()**

Resume file monitoring.

## ENUMERATIONS

**FileWatcherType**

```
ONESHOT = 0
PERIODIC
NEVER
```

**FileWatcherAttribute**

```
ACCESS = IN_ACCESS
CREATE = IN_CREATE
MODIFY = IN_MODIFY
DELETE = IN_DELETE | IN_DELETE_SELF
ATTRIB = IN_ATTRIB
MOVE = IN_MOVE | IN_MOVE_SELF
OPEN = IN_OPEN
CLOSE = IN_CLOSE
ALL = IN_ALL_EVENTS
```

**RecursiveType**

```
DIR = 1 << 0
REGULAR = 1 << 1
HIDDEN = 1 << 2
TMPFILE = 1 << 3
ALLFILE = HIDDEN | TMPFILE | DIR | REGULAR
```

## CONFORMING TO

These functions conform to the withdrawn POSIX.1e draft specification. The following functions are Linux extensions: **addWatchTargetRecursive**(), **addWatchTargetListRecursive**(), **removeWatchTargetRecursive**(), **clearWatchList**(), **pauseWatcher**() and **restartWatcher**().

## SEE ALSO

[**inotify**(7)](/man/inotify/7.md), [**libkyfilewatcher**(3)](/man/libkyfilewatcher/3.md)

## AUTHOR

Generated automatically by Doxygen for libkyfilewatcher.hpp from the source code.
