|
1 | | -STFilePath - API Quick Reference (short) |
2 | | - |
3 | | -STFile (file-level operations) |
4 | | -- create(with: Data) -> create file with contents |
5 | | -- read() -> Data |
6 | | -- append(data: Data) |
7 | | -- delete() |
8 | | -- move(to: STFile) |
9 | | -- hash(with: HashAlgorithm) -> String |
10 | | -- watcher() -> STFileWatcher |
11 | | - |
12 | | -STFolder (folder-level operations) |
13 | | -- folder(name: String) -> STFolder (path builder) |
14 | | -- file(name: String) -> STFile (path builder) |
15 | | -- create() -> create folder |
16 | | -- delete() |
17 | | -- watcher(options:) -> STFolderWatcher |
18 | | - |
19 | | -STPath / STPathProtocol |
20 | | -- path string properties, checks for isExists, isFolderExists, isFileExists |
21 | | -- watcher() -> STPathWatcher (generic) |
22 | | -- openingProcesses() -> [STProcessInfo] (macOS only) |
23 | | - |
24 | | -STProcessInfo |
25 | | -- pid: Int32 |
26 | | -- name: String |
27 | | -- command: String |
28 | | - |
29 | | -Watcher Classes (STFileWatcher, STFolderWatcher, STPathWatcher) |
30 | | -- streamMonitoring() / stream() -> AsyncThrowingStream of events |
31 | | -- stopMonitoring() / stop() -> terminates the stream |
32 | | - |
33 | | -DownloadableFile / DFAnyFile |
34 | | -- .codable(Type.self) to transform to Codable handling |
35 | | -- fetch() async -> Type |
36 | | -- save(_:) async to persist transformed content |
37 | | - |
38 | | -Where to find implementations |
39 | | -- Sources/STFilePath/STFile.swift |
40 | | -- Sources/STFilePath/STFolder+Folder.swift |
41 | | -- Sources/STFilePath/STFolderWatcher.swift |
42 | | -- Sources/STFilePath/STFileWatcher.swift |
43 | | -- Sources/STFilePath/STPathWatcher.swift |
44 | | -- Sources/STFilePath/STPathProtocol.swift |
45 | | -- Sources/STFilePath/DownloadableFile/* |
46 | | - |
47 | | -Note: This reference is intentionally concise. For method signatures and exact parameter types, open the source files listed above. |
| 1 | +STFilePath - API Quick Reference (accurate, terse) |
| 2 | + |
| 3 | +If you need deeper coverage by area, open the matching reference file: |
| 4 | +- File/folder IO: `references/FILE_IO.md` |
| 5 | +- Sandbox/containers: `references/CORE_PATHS_AND_SANDBOX.md` |
| 6 | +- Watchers: `references/WATCHERS.md` |
| 7 | +- Hashing: `references/HASHING.md` |
| 8 | +- Metadata/permissions/xattrs/symlinks: `references/METADATA_PERMISSIONS_XATTR_LINKS.md` |
| 9 | +- MMAP & Darwin: `references/MMAP_AND_DARWIN.md` |
| 10 | +- DownloadableFile: `references/DOWNLOADABLEFILE.md` |
| 11 | +- Search/backup: `references/SEARCH_AND_BACKUP.md` |
| 12 | +- JSON Lines: `references/JSON_LINES.md` |
| 13 | +- Integrations: `references/INTEGRATIONS_IOS_MACOS.md` |
| 14 | + |
| 15 | +Use cases |
| 16 | +1) 我想“直接写代码”而不是翻源码:先看 `references/FUNCTION_COOKBOOK.md` |
| 17 | +2) 我想快速复制粘贴:看 `references/EXAMPLES.md` |
| 18 | +3) 我想改库实现/补测试:先看 `references/FILES.md`(定位实现与测试文件) |
| 19 | + |
| 20 | +Search hints |
| 21 | +- Core protocol: `rg -n "protocol STPathProtocol" Sources/STFilePath` |
| 22 | +- Core types: `rg -n "struct STPath|struct STFile|struct STFolder" Sources/STFilePath` |
| 23 | +- Watchers: `rg -n "Watcher|ST(Folder|File|Path)Watcher|WatcherBackend" Sources/STFilePath` |
| 24 | +- DownloadableFile: `rg -n "protocol DownloadableFile|DFAnyFile|DFFileMap|DFCurrentValueFile" Sources/STFilePath` |
| 25 | + |
| 26 | +Core types |
| 27 | +- `STPathProtocol`: shared URL-based API for paths (exists/type/relativePath, attributes, permission, etc.). Implementation: `Sources/STFilePath/STPathProtocol.swift` |
| 28 | +- `STPath`: type-erased path (file/folder/notExist), can expose `referenceType` as `STFilePathReferenceType`. Implementation: `Sources/STFilePath/STPath.swift` |
| 29 | +- `STFile`: file path + file ops. Implementation: `Sources/STFilePath/STFile.swift` |
| 30 | +- `STFolder`: folder path + folder ops. Implementation: `Sources/STFilePath/STFolder+Folder.swift` |
| 31 | + |
| 32 | +Path classification & reference |
| 33 | +- `STFilePathItemType`: `.file/.folder/.notExist`. Implementation: `Sources/STFilePath/STFilePathItemType.swift` |
| 34 | +- `STFilePathReferenceType`: `.file(STFile)` / `.folder(STFolder)`. Implementation: `Sources/STFilePath/STFilePathReferenceType.swift` |
| 35 | + |
| 36 | +Watchers (AsyncThrowingStream-based) |
| 37 | +- `STFileWatcher(file: STFile).stream() -> AsyncThrowingStream<STPathChanged, Error>` and `.stop()`. Implementation: `Sources/STFilePath/STFileWatcher.swift` |
| 38 | +- `STFolderWatcher(folder: STFolder, options:).streamMonitoring() -> AsyncThrowingStream<STFolderWatcher.Changed, Error>` and `.stopMonitoring()`. Implementation: `Sources/STFilePath/STFolderWatcher.swift` |
| 39 | +- `STPathWatcher(path: STPath).stream() -> AsyncThrowingStream<STPathChanged, Error>` and `.stop()`. Implementation: `Sources/STFilePath/STPathWatcher.swift` |
| 40 | +- Backends: |
| 41 | + - macOS folder/path: FSEvents (`Sources/STFilePath/macos/FSEventsWatcher.swift`) |
| 42 | + - file + non-macOS: DispatchSource (`Sources/STFilePath/DispatchSourceWatcher.swift`) |
| 43 | + - common event model: `Sources/STFilePath/WatcherBackend.swift` (`STPathChanged`, `STPathChangeKind`) |
| 44 | + |
| 45 | +Hashing (CryptoKit) |
| 46 | +- `STHasherKind`: `.sha256/.sha384/.sha512/.md5` (md5 uses `Insecure.MD5`). Implementation: `Sources/STFilePath/STFile+CryptoKit.swift` |
| 47 | +- `STFile.hash(with kind: STHasherKind) -> String` (hex digest). Implementation: `Sources/STFilePath/STFile+CryptoKit.swift` |
| 48 | + |
| 49 | +Metadata / permissions / xattrs / symlinks |
| 50 | +- Attributes wrapper: `STPathAttributes` via `STPathProtocol.attributes`. Implementation: `Sources/STFilePath/STPathAttributes.swift` |
| 51 | +- Convenience permissions: |
| 52 | + - `STPathProtocol.permission -> STPathPermission` (exists/readable/writable/executable/deletable). Implementation: `Sources/STFilePath/STPathProtocol.swift`, `Sources/STFilePath/STPathPermission.swift` |
| 53 | + - POSIX permissions helpers: `STPathProtocol.permissions()` / `set(permissions:)` and `STPathPermission.Posix`. Implementation: `Sources/STFilePath/STPath+Metadata.swift`, `Sources/STFilePath/STPathPermission.swift` |
| 54 | +- Extended attributes (Darwin only): `STPathProtocol.extendedAttributes` with `set/value/remove/list`. Implementation: `Sources/STFilePath/STPath+Metadata.swift` |
| 55 | +- Symlink helpers: `isSymbolicLink`, `createSymbolicLink(to:)`, `destinationOfSymbolicLink()`. Implementation: `Sources/STFilePath/STPath+Link.swift` |
| 56 | +- Security-scoped resource helpers (Apple platforms): `startAccessingSecurityScopedResource()` / `stopAccessingSecurityScopedResource()`. Implementation: `Sources/STFilePath/STPathProtocol.swift` |
| 57 | + |
| 58 | +Search & enumeration |
| 59 | +- `STFolder.files(...) / folders(...) / subFilePaths(...) / allSubFilePaths(...)`. Implementation: `Sources/STFilePath/STFolder+Search.swift` |
| 60 | +- `STFolder.SearchPredicate` and custom filters. Implementation: `Sources/STFilePath/STFolder+Search.swift` |
| 61 | +- Recursive file scanning with filters: `STFolder.files(matching:in:)`. Implementation: `Sources/STFilePath/STFolder+Search.swift` |
| 62 | + |
| 63 | +Backup |
| 64 | +- `STFolder.backup(options:) -> STFolderBackup`, `connect()`, `monitoring() async`, `stopMonitoring()`. Implementation: `Sources/STFilePath/STFolderBackup.swift` |
| 65 | + |
| 66 | +JSON Lines |
| 67 | +- `STFile.lineFile -> STLineFile`, `STLineFile.lines()` / `lines(as:)`, `STLineFile.NewLineWriter.append(...)`. Implementation: `Sources/STFilePath/STJSONLines.swift` |
| 68 | + |
| 69 | +DownloadableFile |
| 70 | +- `DownloadableFile` protocol: `fetch()` / `save(_:) async`. Implementation: `Sources/STFilePath/DownloadableFile/DownloadableFile.swift` |
| 71 | +- `DFAnyFile<Model>` type erasure and `DFAnyFile(file: STFile)` when `Model == Data`. Implementation: `Sources/STFilePath/DownloadableFile/DFAnyFile.swift` |
| 72 | +- `DFFileMap<File, To>` mapping via `map(fetch:save:)` and helpers like `.codable(...)`, `.compression(...)`. Implementation: `Sources/STFilePath/DownloadableFile/DFFileMap.swift`, `Sources/STFilePath/DownloadableFile/DownloadableFile.swift` |
| 73 | +- `DFCurrentValueFile`: debounced-ish “last write wins” wrapper that saves on `value` set. Implementation: `Sources/STFilePath/DownloadableFile/DFAnyFile.swift` |
| 74 | +- Convenience: `STFile.toDFAnyFile() -> DFAnyFile<Data>`. Implementation: `Sources/STFilePath/DownloadableFile/DFAnyFile.swift` |
| 75 | + |
| 76 | +Compression (if `Compression` module available) |
| 77 | +- `STComparator.compress/decompress(_:algorithm:)`. Implementation: `Sources/STFilePath/Compression/STComparator.swift` |
| 78 | +- `DownloadableFile.compression(_:)` for `Model == Data`. Implementation: `Sources/STFilePath/DownloadableFile/DownloadableFile.swift` |
| 79 | + |
| 80 | +MMAP & Darwin file APIs (Darwin only) |
| 81 | +- `STFile.withMmap(...) { STFileMMAP in ... }`, `STFile.setSize(_:)`. Implementation: `Sources/STFilePath/STFile+MMAP.swift` |
| 82 | +- `STFile.system -> STFileSystem` (`open/stat/truncate/sync/...`). Implementation: `Sources/STFilePath/STFile+Darwin.swift` |
| 83 | + |
| 84 | +Integrations |
| 85 | +- iOS: `STDocumentPicker` (UIDocumentPicker) and `STPathQuickLookController` (QuickLook). Implementation: `Sources/STFilePath/ios/*` |
| 86 | +- macOS: Finder helpers (`showInFinder`, `selectInFinder`) and associated apps (`associatedApplications`, `open(with:)`). Implementation: `Sources/STFilePath/macos/*` |
0 commit comments