Download apps/macos/Sources/OpenClaw/ConfigFileWatcher.swift from Darochin/openskynet: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/Darochin/openskynet/resolve/main/apps/macos/Sources/OpenClaw/ConfigFileWatcher.swift
- Command line
-
hf download hf://Darochin/openskynet/apps/macos/Sources/OpenClaw/ConfigFileWatcher.swift
-
curl -L -o ConfigFileWatcher.swift https://huggingface.co/Darochin/openskynet/resolve/main/apps/macos/Sources/OpenClaw/ConfigFileWatcher.swift
1.29 kB
| import Foundation | |
| final class ConfigFileWatcher: @unchecked Sendable, SimpleFileWatcherOwner { | |
| private let url: URL | |
| private let watchedDir: URL | |
| private let targetPath: String | |
| private let targetName: String | |
| let watcher: SimpleFileWatcher | |
| init(url: URL, onChange: @escaping () -> Void) { | |
| self.url = url | |
| self.watchedDir = url.deletingLastPathComponent() | |
| self.targetPath = url.path | |
| self.targetName = url.lastPathComponent | |
| let watchedDirPath = self.watchedDir.path | |
| let targetPath = self.targetPath | |
| let targetName = self.targetName | |
| self.watcher = SimpleFileWatcher(CoalescingFSEventsWatcher( | |
| paths: [watchedDirPath], | |
| queueLabel: "ai.openclaw.configwatcher", | |
| shouldNotify: { _, eventPaths in | |
| guard let eventPaths else { return true } | |
| let paths = unsafeBitCast(eventPaths, to: NSArray.self) | |
| for case let path as String in paths { | |
| if path == targetPath { return true } | |
| if path.hasSuffix("/\(targetName)") { return true } | |
| if path == watchedDirPath { return true } | |
| } | |
| return false | |
| }, | |
| onChange: onChange)) | |
| } | |
| } | |