| 1235 | /// BfpFileWatcher |
| 1236 | |
| 1237 | BFP_EXPORT BfpFileWatcher* BFP_CALLTYPE BfpFileWatcher_WatchDirectory(const char* path, BfpDirectoryChangeFunc callback, BfpFileWatcherFlags flags, void* userData, BfpFileResult* outResult) |
| 1238 | { |
| 1239 | HANDLE directoryHandle = CreateFileW( |
| 1240 | UTF8Decode(path).c_str(), // Directory name |
| 1241 | FILE_LIST_DIRECTORY, // access (read-write) mode |
| 1242 | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
| 1243 | NULL, // security descriptor |
| 1244 | OPEN_EXISTING, |
| 1245 | FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, // file attributes |
| 1246 | NULL // file with attributes to copy |
| 1247 | ); |
| 1248 | |
| 1249 | if (!IsHandleValid(directoryHandle)) |
| 1250 | { |
| 1251 | OUTRESULT(BfpFileResult_UnknownError); |
| 1252 | return NULL; |
| 1253 | } |
| 1254 | |
| 1255 | BfpFileWatcher* fileWatcher = new BfpFileWatcher(); |
| 1256 | fileWatcher->mKind = BfpOverlappedKind_FileWatcher; |
| 1257 | fileWatcher->mPath = path; |
| 1258 | fileWatcher->mDirectoryChangeFunc = callback; |
| 1259 | fileWatcher->mHandle = directoryHandle; |
| 1260 | fileWatcher->mFlags = flags; |
| 1261 | fileWatcher->mUserData = userData; |
| 1262 | IOCPManager::Get()->Add(fileWatcher); |
| 1263 | fileWatcher->Monitor(); |
| 1264 | |
| 1265 | return fileWatcher; |
| 1266 | } |
| 1267 | |
| 1268 | BFP_EXPORT void BFP_CALLTYPE BfpFileWatcher_Release(BfpFileWatcher* fileWatcher) |
| 1269 | { |
nothing calls this directly
no test coverage detected