-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/document-with-docc' into develop
- Loading branch information
Showing
58 changed files
with
627 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,24 @@ | ||
# FileSystemEventPublisher | ||
A publisher that emits events in the file system. | ||
|
||
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fkennethlaskoski%2FFileSystemEventPublisher%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/kennethlaskoski/FileSystemEventPublisher) | ||
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fkennethlaskoski%2FFileSystemEventPublisher%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/kennethlaskoski/FileSystemEventPublisher) | ||
# ``FileSystemEventPublisher`` | ||
|
||
A publisher that emits events in the file system. | ||
|
||
## Example usage: | ||
## Overview | ||
|
||
``` | ||
let id = UUID() | ||
let tmpURL = FileManager.default.temporaryDirectory | ||
let url = URL(fileURLWithPath: "\(id)", relativeTo: tmpURL) | ||
let tmp = try! FileDescriptor.open(tmpURL.path, .readOnly, options: .eventOnly) | ||
The FileSystemEventPublisher framework wraps a [Combine Publisher](https://developer.apple.com/documentation/combine/publisher) | ||
around a [DispatchSourceFileSystemObject](https://developer.apple.com/documentation/dispatch/dispatchsourcefilesystemobject), | ||
providing a modern high-level interface to an efficient way of monitoring filesystem events. | ||
|
||
var received = DispatchSource.FileSystemEvent() | ||
## Usage | ||
|
||
print(received) // prints "FileSystemEvent(rawValue: 0)" | ||
A typealias and a function are all the exposed interface, the Combine framework provides all remaining functionality. | ||
|
||
let cancellable = DispatchSource.publish(at: tmp) | ||
.sink { event in | ||
received = event | ||
} | ||
The publisher is created by a function with two parameters: a file and a set of events; this signature reflects the | ||
underlying DispatchSource interface and was adopted for it's simplicity and performance. | ||
|
||
try! FileManager.default.createDirectory(at: url, withIntermediateDirectories: false, attributes: nil) | ||
sleep(1) | ||
The first parameter is a mask containing events of interest. The set of events are defined by a typealias to | ||
[DispatchSoutce.FileSystemEvent](https://developer.apple.com/documentation/dispatch/dispatchsource/filesystemevent). | ||
This type is also the Output of the created publisher, i.e., the type of values to be delivered to subscribers. | ||
|
||
print(received) // prints "FileSystemEvent(rawValue: 18)" | ||
The second parameter is a [FileDescriptor](https://developer.apple.com/documentation/system/filedescriptor) pointing to an open file, folder or socket. | ||
|
||
cancellable.cancel() | ||
``` | ||
The package includes a playground with a short example code. |
32 changes: 32 additions & 0 deletions
32
Sources/FileSystemEventPublisher/Documentation.docc/Documentation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# ``FileSystemEventPublisher`` | ||
|
||
A publisher that emits events in the file system. | ||
|
||
## Overview | ||
|
||
The FileSystemEventPublisher framework wraps a [Combine Publisher](https://developer.apple.com/documentation/combine/publisher) | ||
around a [DispatchSourceFileSystemObject](https://developer.apple.com/documentation/dispatch/dispatchsourcefilesystemobject), | ||
providing a modern high-level interface to an efficient way of monitoring filesystem events. | ||
|
||
## Usage | ||
|
||
A typealias and a function are all the exposed interface, the Combine framework provides all remaining functionality. | ||
|
||
The publisher is created by a function with two parameters: a file and a set of events; this signature reflects the | ||
underlying DispatchSource interface and was adopted for it's simplicity and performance. | ||
|
||
The first parameter is a mask containing events of interest. The set of events are defined by a typealias to | ||
[DispatchSoutce.FileSystemEvent](https://developer.apple.com/documentation/dispatch/dispatchsource/filesystemevent). | ||
This type is also the Output of the created publisher, i.e., the type of values to be delivered to subscribers. | ||
|
||
The second parameter is a [FileDescriptor](https://developer.apple.com/documentation/system/filedescriptor) pointing to an open file, folder or socket. | ||
|
||
## Topics | ||
|
||
### Values | ||
|
||
- ``Event`` | ||
|
||
### Creating a publisher | ||
|
||
- ``monitor(_:for:)`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
docs/css/documentation-topic~topic~tutorials-overview.67b822e0.css
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"primaryContentSections":[{"kind":"content","content":[{"anchor":"Overview","level":2,"type":"heading","text":"Overview"},{"type":"paragraph","inlineContent":[{"type":"text","text":"The FileSystemEventPublisher framework wraps a "},{"type":"reference","isActive":true,"identifier":"https:\/\/developer.apple.com\/documentation\/combine\/publisher"},{"type":"text","text":" "},{"type":"text","text":"around a "},{"type":"reference","isActive":true,"identifier":"https:\/\/developer.apple.com\/documentation\/dispatch\/dispatchsourcefilesystemobject"},{"type":"text","text":","},{"type":"text","text":" "},{"type":"text","text":"providing a modern high-level interface to an efficient way of monitoring filesystem events."}]},{"anchor":"Usage","level":2,"type":"heading","text":"Usage"},{"type":"paragraph","inlineContent":[{"type":"text","text":"A typealias and a function are all the exposed interface, the Combine framework provides all remaining functionality."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"The publisher is created by a function with two parameters: a file and a set of events; this signature reflects the"},{"type":"text","text":" "},{"type":"text","text":"underlying DispatchSource interface and was adopted for it’s simplicity and performance."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"The first parameter is a mask containing events of interest. The set of events are defined by a typealias to"},{"type":"text","text":" "},{"type":"reference","isActive":true,"identifier":"https:\/\/developer.apple.com\/documentation\/dispatch\/dispatchsource\/filesystemevent"},{"type":"text","text":"."},{"type":"text","text":" "},{"type":"text","text":"This type is also the Output of the created publisher, i.e., the type of values to be delivered to subscribers."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"The second parameter is a "},{"type":"reference","isActive":true,"identifier":"https:\/\/developer.apple.com\/documentation\/system\/filedescriptor"},{"type":"text","text":" pointing to an open file, folder or socket."}]}]}],"schemaVersion":{"major":0,"minor":2,"patch":0},"sections":[],"variants":[{"paths":["\/documentation\/filesystemeventpublisher"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"A publisher that emits events in the file system."}],"kind":"symbol","metadata":{"roleHeading":"Framework","externalID":"FileSystemEventPublisher","title":"FileSystemEventPublisher","symbolKind":"module","role":"collection","modules":[{"name":"FileSystemEventPublisher"}]},"hierarchy":{"paths":[[]]},"topicSections":[{"title":"Values","identifiers":["doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher\/Event"]},{"title":"Creating a publisher","identifiers":["doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher\/monitor(_:for:)"]}],"references":{"https://developer.apple.com/documentation/system/filedescriptor":{"title":"FileDescriptor","titleInlineContent":[{"type":"text","text":"FileDescriptor"}],"type":"link","identifier":"https:\/\/developer.apple.com\/documentation\/system\/filedescriptor","url":"https:\/\/developer.apple.com\/documentation\/system\/filedescriptor"},"doc://FileSystemEventPublisher/documentation/FileSystemEventPublisher/Event":{"role":"symbol","title":"Event","fragments":[{"kind":"keyword","text":"typealias"},{"kind":"text","text":" "},{"kind":"identifier","text":"Event"}],"abstract":[{"type":"text","text":"Events involving a change to a file system object."}],"identifier":"doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher\/Event","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"Event"}],"url":"\/documentation\/filesystemeventpublisher\/event"},"doc://FileSystemEventPublisher/documentation/FileSystemEventPublisher/monitor(_:for:)":{"role":"symbol","title":"monitor(_:for:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"monitor"},{"kind":"text","text":"("},{"kind":"typeIdentifier","text":"FileDescriptor","preciseIdentifier":"s:6System14FileDescriptorV"},{"kind":"text","text":", "},{"kind":"externalParam","text":"for"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"Event","preciseIdentifier":"s:24FileSystemEventPublisher0C0a"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","text":"AnyPublisher","preciseIdentifier":"s:7Combine12AnyPublisherV"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","text":"Event","preciseIdentifier":"s:24FileSystemEventPublisher0C0a"},{"kind":"text","text":", "},{"kind":"typeIdentifier","text":"Never","preciseIdentifier":"s:s5NeverO"},{"kind":"text","text":">"}],"abstract":[{"type":"text","text":"Creates a new publisher for monitoring file system events."}],"identifier":"doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher\/monitor(_:for:)","kind":"symbol","type":"topic","url":"\/documentation\/filesystemeventpublisher\/monitor(_:for:)"},"doc://FileSystemEventPublisher/documentation/FileSystemEventPublisher":{"role":"collection","title":"FileSystemEventPublisher","abstract":[{"type":"text","text":"A publisher that emits events in the file system."}],"identifier":"doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher","kind":"symbol","type":"topic","url":"\/documentation\/filesystemeventpublisher"},"https://developer.apple.com/documentation/dispatch/dispatchsource/filesystemevent":{"title":"DispatchSoutce.FileSystemEvent","titleInlineContent":[{"type":"text","text":"DispatchSoutce.FileSystemEvent"}],"type":"link","identifier":"https:\/\/developer.apple.com\/documentation\/dispatch\/dispatchsource\/filesystemevent","url":"https:\/\/developer.apple.com\/documentation\/dispatch\/dispatchsource\/filesystemevent"},"https://developer.apple.com/documentation/dispatch/dispatchsourcefilesystemobject":{"title":"DispatchSourceFileSystemObject","titleInlineContent":[{"type":"text","text":"DispatchSourceFileSystemObject"}],"type":"link","identifier":"https:\/\/developer.apple.com\/documentation\/dispatch\/dispatchsourcefilesystemobject","url":"https:\/\/developer.apple.com\/documentation\/dispatch\/dispatchsourcefilesystemobject"},"https://developer.apple.com/documentation/combine/publisher":{"title":"Combine Publisher","titleInlineContent":[{"type":"text","text":"Combine Publisher"}],"type":"link","identifier":"https:\/\/developer.apple.com\/documentation\/combine\/publisher","url":"https:\/\/developer.apple.com\/documentation\/combine\/publisher"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"primaryContentSections":[{"kind":"declarations","declarations":[{"tokens":[{"kind":"keyword","text":"typealias"},{"kind":"text","text":" "},{"kind":"identifier","text":"Event"},{"kind":"text","text":" = "},{"kind":"typeIdentifier","text":"DispatchSource","preciseIdentifier":"c:objc(cs)OS_dispatch_source"},{"kind":"text","text":"."},{"kind":"typeIdentifier","text":"FileSystemEvent","preciseIdentifier":"s:So18OS_dispatch_sourceC8DispatchE15FileSystemEventV"}],"languages":["swift"],"platforms":["macOS"]}]}],"schemaVersion":{"major":0,"minor":2,"patch":0},"sections":[],"variants":[{"paths":["\/documentation\/filesystemeventpublisher\/event"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher\/Event","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"Events involving a change to a file system object."}],"kind":"symbol","metadata":{"fragments":[{"kind":"keyword","text":"typealias"},{"kind":"text","text":" "},{"kind":"identifier","text":"Event"}],"title":"Event","roleHeading":"Type Alias","role":"symbol","symbolKind":"typealias","externalID":"s:24FileSystemEventPublisher0C0a","modules":[{"name":"FileSystemEventPublisher"}],"navigatorTitle":[{"kind":"identifier","text":"Event"}]},"hierarchy":{"paths":[["doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher"]]},"references":{"doc://FileSystemEventPublisher/documentation/FileSystemEventPublisher/Event":{"role":"symbol","title":"Event","fragments":[{"kind":"keyword","text":"typealias"},{"kind":"text","text":" "},{"kind":"identifier","text":"Event"}],"abstract":[{"type":"text","text":"Events involving a change to a file system object."}],"identifier":"doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher\/Event","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"Event"}],"url":"\/documentation\/filesystemeventpublisher\/event"},"doc://FileSystemEventPublisher/documentation/FileSystemEventPublisher":{"role":"collection","title":"FileSystemEventPublisher","abstract":[{"type":"text","text":"A publisher that emits events in the file system."}],"identifier":"doc:\/\/FileSystemEventPublisher\/documentation\/FileSystemEventPublisher","kind":"symbol","type":"topic","url":"\/documentation\/filesystemeventpublisher"}}} |
Oops, something went wrong.