├── .gitignore
├── .jazzy.yaml
├── .travis.yml
├── LICENSE
├── Package.swift
├── README.md
├── Sources
└── FileKit
│ └── FileKit.swift
├── Tests
├── FileKitTests
│ └── FileKitTests.swift
└── LinuxMain.swift
├── docker-compose.yml
└── docs
├── Classes.html
├── Classes
└── FileKit.html
├── badge.svg
├── css
├── highlight.css
└── jazzy.css
├── docsets
├── FileKit.docset
│ └── Contents
│ │ ├── Info.plist
│ │ └── Resources
│ │ ├── Documents
│ │ ├── Classes.html
│ │ ├── Classes
│ │ │ └── FileKit.html
│ │ ├── css
│ │ │ ├── highlight.css
│ │ │ └── jazzy.css
│ │ ├── img
│ │ │ ├── carat.png
│ │ │ ├── dash.png
│ │ │ ├── gh.png
│ │ │ └── spinner.gif
│ │ ├── index.html
│ │ ├── js
│ │ │ ├── jazzy.js
│ │ │ ├── jazzy.search.js
│ │ │ ├── jquery.min.js
│ │ │ ├── lunr.min.js
│ │ │ └── typeahead.jquery.js
│ │ └── search.json
│ │ └── docSet.dsidx
└── FileKit.tgz
├── img
├── carat.png
├── dash.png
├── gh.png
└── spinner.gif
├── index.html
├── js
├── jazzy.js
├── jazzy.search.js
├── jquery.min.js
├── lunr.min.js
└── typeahead.jquery.js
├── search.json
└── undocumented.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 | *.xcodeproj
5 |
6 | ## Build generated
7 | build/
8 | DerivedData/
9 |
10 | ## Various settings
11 | *.pbxuser
12 | !default.pbxuser
13 | *.mode1v3
14 | !default.mode1v3
15 | *.mode2v3
16 | !default.mode2v3
17 | *.perspectivev3
18 | !default.perspectivev3
19 | xcuserdata/
20 |
21 | ## Other
22 | *.moved-aside
23 | *.xcuserstate
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | ## Playgrounds
32 | timeline.xctimeline
33 | playground.xcworkspace
34 |
35 | # Swift Package Manager
36 | #
37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38 | # Packages/
39 | .build/
40 | .build-ubuntu/
41 | Packages/
42 | Package.resolved
43 |
44 | # CocoaPods
45 | #
46 | # We recommend against adding the Pods directory to your .gitignore. However
47 | # you should judge for yourself, the pros and cons are mentioned at:
48 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
49 | #
50 | # Pods/
51 |
52 | # Carthage
53 | #
54 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
55 | # Carthage/Checkouts
56 |
57 | Carthage/Build
58 |
59 | # fastlane
60 | #
61 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
62 | # screenshots whenever they are needed.
63 | # For more information about the recommended setup visit:
64 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
65 |
66 | fastlane/report.xml
67 | fastlane/Preview.html
68 | fastlane/screenshots
69 | fastlane/test_output
70 |
--------------------------------------------------------------------------------
/.jazzy.yaml:
--------------------------------------------------------------------------------
1 | module: FileKit
2 | author: IBM & Kitura project authors
3 | github_url: https://github.com/Kitura/FileKit/
4 |
5 | theme: fullwidth
6 | clean: true
7 | exclude: [Packages]
8 |
9 | readme: README.md
10 |
11 | skip_undocumented: false
12 | hide_documentation_coverage: false
13 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # Travis CI build file.
2 |
3 | # whitelist (branches that should be built)
4 | branches:
5 | only:
6 | - master
7 | - /^issue.*$/
8 |
9 | # the matrix of builds should cover each combination of Swift version
10 | # and platform that is supported. The version of Swift used is specified
11 | # by .swift-version, unless SWIFT_SNAPSHOT is specified.
12 | matrix:
13 | include:
14 | - os: linux
15 | dist: xenial
16 | sudo: required
17 | services: docker
18 | env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:5.2.5
19 | - os: linux
20 | dist: xenial
21 | sudo: required
22 | services: docker
23 | env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:5.4.1 SWIFT_TEST_ARGS="--parallel "
24 | - os: linux
25 | dist: xenial
26 | sudo: required
27 | services: docker
28 | env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu20.04:5.5.2 KITURA_NIO=1 SWIFT_TEST_ARGS="--parallel "
29 | - os: osx
30 | osx_image: xcode12.2
31 | sudo: required
32 | - os: osx
33 | osx_image: xcode13.3
34 | sudo: required
35 | env: JAZZY_ELIGIBLE=true
36 |
37 | before_install:
38 | - git clone https://github.com/Kitura/Package-Builder.git
39 |
40 | script:
41 | - ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.2
2 | // The swift-tools-version declares the minimum version of Swift required to build this package.
3 |
4 | import PackageDescription
5 |
6 | let package = Package(
7 | name: "FileKit",
8 | products: [
9 | // Products define the executables and libraries produced by a package, and make them visible to other packages.
10 | .library(
11 | name: "FileKit",
12 | targets: ["FileKit"]),
13 | ],
14 | dependencies: [
15 | // Dependencies declare other packages that this package depends on.
16 | .package(url: "https://github.com/Kitura/LoggerAPI.git", .upToNextMajor(from: "2.0.0"))
17 | ],
18 | targets: [
19 | // Targets are the basic building blocks of a package. A target can define a module or a test suite.
20 | // Targets can depend on other targets in this package, and on products in packages which this package depends on.
21 | .target(
22 | name: "FileKit",
23 | dependencies: ["LoggerAPI"]),
24 | .testTarget(
25 | name: "FileKitTests",
26 | dependencies: ["FileKit"]),
27 | ]
28 | )
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
21 |
22 | # FileKit
23 |
24 | Resolves commonly used paths, including the project, executable and working directories.
25 |
26 | ## Version
27 | The latest release of `FileKit` (0.x.x) runs on Swift 5.2 and newer, on both macOS and Ubuntu Linux.
28 |
29 | ## Usage
30 |
31 | ### Add dependencies
32 |
33 | Add `FileKit` to the dependencies within your application's `Package.swift` file. Substitute `"x.x.x"` with the latest `FileKit` [release](https://github.com/Kitura/FileKit/releases).
34 |
35 | ```swift
36 | .package(url: "https://github.com/Kitura/FileKit.git", from: "x.x.x")
37 | ```
38 | Add `FileKit` to your target's dependencies:
39 |
40 | ```Swift
41 | .target(name: "example", dependencies: ["FileKit"]),
42 | ```
43 |
44 | #### Import package
45 |
46 | ```swift
47 | import FileKit
48 | ```
49 |
50 | You will also need to import the `Foundation` package if you're handling URLs:
51 |
52 | ```swift
53 | import Foundation
54 | ```
55 |
56 | ## Supported Paths
57 |
58 | #### Path to Executable Folder
59 |
60 | Points to the folder containing the project executable.
61 |
62 | For example, when running an executable called `MySwiftProject` within Xcode the executable folder string would be "/Users/username/MySwiftProject/.build/debug", when running the same project from the command line this would be "/Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug".
63 |
64 | ```swift
65 | /// Executable Folder String
66 | let stringUrl = FileKit.executableFolder
67 |
68 | /// Executable Folder URL
69 | let urlObject = FileKit.executableFolderURL
70 |
71 | /// Executable File
72 | let urlObject = FileKit.executableURL
73 | ```
74 |
75 | Note, the `executableURL` will be different when running inside Xcode versus running from the command line.
76 | For example, when running an executable called `MySwiftProject`:
77 | - Running on the command line - `file:///Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug/MySwiftProject`
78 | - Running within Xcode - `file:///Users/username/Library/Developer/Xcode/DerivedData/MySwiftProject-fjgfjmxrlbhzkhfmxdgeipylyeay/Build/Products/Debug/MySwiftProject`.
79 |
80 | #### Path to Project Folder
81 |
82 | Points to the directory containing the `Package.swift` of the project (as determined by traversing up the directory structure starting at the directory containing the executable), or if no `Package.swift` is found then the directory containing the executable.
83 |
84 | ```swift
85 | /// Absolute path to the project's root folder
86 | let stringUrl = FileKit.projectFolder
87 |
88 | /// URL to the project's root folder
89 | let urlObject = FileKit.projectFolderURL
90 | ```
91 |
92 | #### Path to Working Directory
93 |
94 | Provides the standardized working directory, while accounting for environmental changes. When running in Xcode, this returns the directory containing the `Package.swift` of the project, while outside Xcode it returns the current working directory.
95 |
96 | ```swift
97 | /// Absolute path to the present working directory
98 | let stringUrl = FileKit.workingDirectory
99 |
100 | /// URL to the project's root folder
101 | let urlObject = FileKit.workingDirectoryURL
102 | ```
103 |
104 | #### Native Swift File Utilities
105 |
106 | Note. As this is native Swift functionality you can use this without importing FileKit.
107 |
108 | ```swift
109 | /// URL pointing to the current source file when it was compiled.
110 | let stringUrl = URL(fileURLWithPath: #file)
111 | ```
112 |
113 | ## API documentation
114 |
115 | For more information visit our [API reference](http://kitura.github.io/FileKit/).
116 |
117 | ## Community
118 |
119 | We love to talk server-side Swift, and Kitura. Join our [Slack](http://swift-at-ibm-slack.mybluemix.net/) to meet the team!
120 |
121 | ## License
122 |
123 | This library is licensed under Apache 2.0. Full license text is available in [LICENSE](https://github.com/Kitura/FileKit/blob/master/LICENSE).
124 |
--------------------------------------------------------------------------------
/Sources/FileKit/FileKit.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright IBM Corporation 2017
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | import Foundation
18 | import LoggerAPI
19 |
20 | /// Resolves commonly used paths, including the project, executable and working directories.
21 | public class FileKit {
22 |
23 | // MARK: Path to Executable Folder
24 |
25 | /// The absolute path to the folder containing the project executable.
26 | ///
27 | /// For example, when running an executable called `MySwiftProject` within Xcode this would be "/Users/username/MySwiftProject/.build/debug", when running the same project from the command line this would be "/Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug".
28 | /// ### Usage Example: ###
29 | /// ```swift
30 | /// let urlString = FileKit.executableFolder
31 | /// ```
32 | public static let executableFolder: String = executableFolderURL.path
33 |
34 | /// URL that points to the directory containing the project executable, or, if run from inside Xcode,
35 | /// the `/.build/debug` folder in the project's root folder.
36 | ///
37 | /// For example when running an executable called `MySwiftProject` within Xcode this would be
38 | /// `file:///Users/username/MySwiftProject/.build/debug/`.
39 | /// ### Usage Example: ###
40 | /// ```swift
41 | /// let urlObject = FileKit.executableFolderURL
42 | /// ```
43 | public static let executableFolderURL: URL = { () -> URL in
44 | if isRanInsideXcode || isRanFromXCTest {
45 | // Get URL to /debug manually
46 | let sourceFile = sourceFileURL.path
47 |
48 | if let range = sourceFile.range(of: "/checkouts/") {
49 | // In Swift 4.0 and newer, package source code is downloaded to //checkouts
50 | return URL(fileURLWithPath: sourceFile[.., assume /.build instead
54 | return URL(fileURLWithPath: sourceFile[.. URL in
81 | #if os(Linux)
82 | // Bundle is not available on Linux yet
83 | // Get path to executable via /proc/self/exe
84 | // https://unix.stackexchange.com/questions/333225/which-process-is-proc-self-for
85 | return URL(fileURLWithPath: "/proc/self/exe")
86 | #else
87 | // Bundle is available on Darwin
88 | return (Bundle.main.executableURL ?? URL(fileURLWithPath: CommandLine.arguments[0]))
89 | #endif
90 | }().resolvingSymlinksInPath()
91 |
92 | // MARK: Path to Project Folder
93 |
94 | /// Absolute path to the directory containing the `Package.swift` of the project (as determined by
95 | /// traversing up the directory structure starting at the directory containing the executable), or
96 | /// if no `Package.swift` is found then the directory containing the executable.
97 | ///
98 | /// For example, when running an executable called `MySwiftProject` this would be something like:
99 | /// `/Users/username/MySwiftProject`.
100 | ///
101 | /// ### Usage Example: ###
102 | /// ```swift
103 | /// let urlString = FileKit.projectFolder
104 | /// ```
105 | public static let projectFolder: String = projectFolderURL.path
106 |
107 | /// URL that points to the directory containing the `Package.swift` of the project (as determined
108 | /// by traversing up the directory structure starting at the directory containing the executable),
109 | /// or if no `Package.swift` is found then the directory containing the executable.
110 | ///
111 | /// For example, when running an executable called `MySwiftProject` this would be something like:
112 | /// `file:///Users/username/MySwiftProject/`.
113 | ///
114 | /// ### Usage Example: ###
115 | /// ```swift
116 | /// let urlObject = FileKit.projectFolderURL
117 | /// ```
118 | public static let projectFolderURL: URL = { () -> URL in
119 | guard let url = projectHeadIterator(executableFolderURL) else {
120 | Log.warning("No Package.swift found. Using executable folder as project folder.")
121 | return executableFolderURL
122 | }
123 |
124 | return url
125 |
126 | }().standardized
127 |
128 | // MARK: Path to Working Directory
129 |
130 | /// Provides the standardized working directory accounting for environmental changes.
131 | /// When running in Xcode, this returns the directory containing the `Package.swift` of the project,
132 | /// while outside Xcode it returns the current working directory.
133 | /// ### Usage Example: ###
134 | /// ```swift
135 | /// let urlString = FileKit.workingDirectory
136 | /// ```
137 | public static let workingDirectory: String = workingDirectoryURL.path
138 |
139 | /// URL that points to the standardized working directory accounting for environmental changes.
140 | /// When running in Xcode, this returns the directory containing the `Package.swift` of the project,
141 | /// while outside Xcode it returns the current working directory.
142 | /// ### Usage Example: ###
143 | /// ```swift
144 | /// let urlObject = FileKit.workingDirectoryURL
145 | /// ```
146 | public static let workingDirectoryURL: URL = { () -> URL in
147 | guard isRanInsideXcode || isRanFromXCTest, let url = projectHeadIterator(executableFolderURL) else {
148 | return URL(fileURLWithPath: "")
149 | }
150 |
151 | Log.debug("Running from Xcode or XCTest. Using project folder as pwd folder.")
152 |
153 | return url
154 |
155 | }().standardized
156 |
157 | }
158 |
159 | // Environment Information
160 | private extension FileKit {
161 |
162 | /// Indicates whether a code is executed from within XCTestCase (i.e. the executable is XCTest)
163 | private static let isRanFromXCTest: Bool = executableURL.path.hasSuffix("/xctest")
164 |
165 | /// Indicates whether a program is ran from inside Xcode
166 | /// (i.e. the executable's path contains /DerivedData)
167 | private static let isRanInsideXcode: Bool = executableURL.path.range(of: "/DerivedData/") != nil
168 |
169 | }
170 |
171 | /// FileKit extension defining private helper methods
172 | private extension FileKit {
173 |
174 | /// URL pointing to this source file
175 | private static let sourceFileURL: URL = URL(fileURLWithPath: #file)
176 |
177 | /// Takes a starting directory and iterates down the tree to find package.swift (the root directory)
178 | private static let projectHeadIterator = { (startingDir: URL) -> URL? in
179 | let fileManager = FileManager()
180 | var startingDir = startingDir.appendingPathComponent("dummy")
181 |
182 | repeat {
183 | startingDir.appendPathComponent("..")
184 | startingDir.standardize()
185 | let packageFilePath = startingDir.appendingPathComponent("Package.swift").path
186 |
187 | if fileManager.fileExists(atPath: packageFilePath) {
188 | return startingDir
189 | }
190 | } while startingDir.path != "/"
191 |
192 | return nil
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/Tests/FileKitTests/FileKitTests.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 | import Foundation
3 | @testable import FileKit
4 |
5 | class FileKitTests: XCTestCase {
6 |
7 | static var allTests = [
8 | ("testExecutablePathResolution", testExecutablePathResolution),
9 | ("testProjectPathResolution", testProjectPathResolution),
10 | ("testWorkingDirectoryPathResolution", testWorkingDirectoryPathResolution),
11 | ]
12 |
13 | func testExecutablePathResolution() {
14 | let executableURL = FileKit.executableURL
15 | let executableFolder = FileKit.executableFolder
16 | let executableFolderURL = FileKit.executableFolderURL
17 |
18 | XCTAssertEqual(executableFolderURL.path, executableFolder)
19 | #if os(Linux)
20 | XCTAssertEqual(executableFolderURL.pathComponents.suffix(4), ["FileKit", ".build", "x86_64-unknown-linux-gnu", "debug" ])
21 | XCTAssertEqual(executableFolderURL.lastPathComponent, "debug")
22 | XCTAssertEqual(executableURL.pathComponents.suffix(2), ["debug", "FileKitPackageTests.xctest"])
23 | #else
24 | XCTAssertEqual(executableFolderURL.lastPathComponent, "Agents")
25 | XCTAssertEqual(executableURL.pathComponents.suffix(2), ["Agents", "xctest"])
26 | #endif
27 | }
28 |
29 | func testProjectPathResolution() {
30 | let projectFolder = FileKit.projectFolder
31 | let projectFolderURL = FileKit.projectFolderURL
32 |
33 | XCTAssertEqual(projectFolderURL.path, projectFolder)
34 |
35 | #if os(Linux)
36 | XCTAssertEqual(projectFolderURL.lastPathComponent, "FileKit")
37 | #else
38 | XCTAssertEqual(projectFolderURL.lastPathComponent, "Agents")
39 | #endif
40 | }
41 |
42 | func testWorkingDirectoryPathResolution() {
43 | let workingDirectory = FileKit.workingDirectory
44 | let workingDirectoryURL = FileKit.workingDirectoryURL
45 |
46 | XCTAssertEqual(workingDirectoryURL.path, workingDirectory)
47 |
48 | #if os(Linux)
49 | XCTAssertEqual(workingDirectoryURL.lastPathComponent, "FileKit")
50 | #else
51 | let expectedPath = URL(fileURLWithPath: "").path == "/private/tmp" ? "tmp" : "FileKit"
52 | XCTAssertEqual(workingDirectoryURL.lastPathComponent, expectedPath)
53 | #endif
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Tests/LinuxMain.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 | @testable import FileKitTests
3 |
4 | XCTMain([
5 | testCase(FileKitTests.allTests),
6 | ])
7 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | app:
2 | image: ibmcom/swift-ubuntu:4.0.2
3 | ports:
4 | - "8080:8080"
5 | volumes:
6 | - .:/FileKit
7 | command: bash -c "cd /FileKit && swift package --build-path .build-ubuntu clean && swift build --build-path .build-ubuntu && swift test"
8 |
--------------------------------------------------------------------------------
/docs/Classes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Classes Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
The absolute path to the folder containing the project executable.
104 |
105 |
For example, when running an executable called MySwiftProject within Xcode this would be /Users/username/MySwiftProject/.build/debug, when running the same project from the command line this would be /Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug.
URL that points to the directory containing the project executable, or, if run from inside Xcode,
136 | the /.build/debug folder in the project’s root folder.
137 |
138 |
For example when running an executable called MySwiftProject within Xcode this would be
139 | file:///Users/username/MySwiftProject/.build/debug/.
Absolute path to the directory containing the Package.swift of the project (as determined by
231 | traversing up the directory structure starting at the directory containing the executable), or
232 | if no Package.swift is found then the directory containing the executable.
233 |
234 |
For example, when running an executable called MySwiftProject this would be something like:
235 | /Users/username/MySwiftProject.
URL that points to the directory containing the Package.swift of the project (as determined
266 | by traversing up the directory structure starting at the directory containing the executable),
267 | or if no Package.swift is found then the directory containing the executable.
268 |
269 |
For example, when running an executable called MySwiftProject this would be something like:
270 | file:///Users/username/MySwiftProject/.
Provides the standardized working directory accounting for environmental changes.
312 | When running in Xcode, this returns the directory containing the Package.swift of the project,
313 | while outside Xcode it returns the current working directory.
URL that points to the standardized working directory accounting for environmental changes.
344 | When running in Xcode, this returns the directory containing the Package.swift of the project,
345 | while outside Xcode it returns the current working directory.
The absolute path to the folder containing the project executable.
104 |
105 |
For example, when running an executable called MySwiftProject within Xcode this would be /Users/username/MySwiftProject/.build/debug, when running the same project from the command line this would be /Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug.
URL that points to the directory containing the project executable, or, if run from inside Xcode,
136 | the /.build/debug folder in the project’s root folder.
137 |
138 |
For example when running an executable called MySwiftProject within Xcode this would be
139 | file:///Users/username/MySwiftProject/.build/debug/.
Absolute path to the directory containing the Package.swift of the project (as determined by
231 | traversing up the directory structure starting at the directory containing the executable), or
232 | if no Package.swift is found then the directory containing the executable.
233 |
234 |
For example, when running an executable called MySwiftProject this would be something like:
235 | /Users/username/MySwiftProject.
URL that points to the directory containing the Package.swift of the project (as determined
266 | by traversing up the directory structure starting at the directory containing the executable),
267 | or if no Package.swift is found then the directory containing the executable.
268 |
269 |
For example, when running an executable called MySwiftProject this would be something like:
270 | file:///Users/username/MySwiftProject/.
Provides the standardized working directory accounting for environmental changes.
312 | When running in Xcode, this returns the directory containing the Package.swift of the project,
313 | while outside Xcode it returns the current working directory.
URL that points to the standardized working directory accounting for environmental changes.
344 | When running in Xcode, this returns the directory containing the Package.swift of the project,
345 | while outside Xcode it returns the current working directory.
You will also need to import the Foundation package if you’re handling URLs:
108 |
importFoundation
109 |
110 |
Supported Paths
111 |
Path to Executable Folder
112 |
113 |
Points to the folder containing the project executable.
114 |
115 |
For example, when running an executable called MySwiftProject within Xcode the executable folder string would be /Users/username/MySwiftProject/.build/debug, when running the same project from the command line this would be /Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug.
Note, the executableURL will be different when running inside Xcode versus running from the command line.
127 | For example, when running an executable called MySwiftProject:
128 |
129 |
130 |
Running on the command line - file:///Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug/MySwiftProject
131 |
Running within Xcode - file:///Users/username/Library/Developer/Xcode/DerivedData/MySwiftProject-fjgfjmxrlbhzkhfmxdgeipylyeay/Build/Products/Debug/MySwiftProject.
132 |
133 |
Path to Project Folder
134 |
135 |
Points to the directory containing the Package.swift of the project (as determined by traversing up the directory structure starting at the directory containing the executable), or if no Package.swift is found then the directory containing the executable.
136 |
/// Absolute path to the project's root folder
137 | letstringUrl=FileKit.projectFolder
138 |
139 | /// URL to the project's root folder
140 | leturlObject=FileKit.projectFolderURL
141 |
142 |
Path to Working Directory
143 |
144 |
Provides the standardized working directory, while accounting for environmental changes. When running in Xcode, this returns the directory containing the Package.swift of the project, while outside Xcode it returns the current working directory.
145 |
/// Absolute path to the present working directory
146 | letstringUrl=FileKit.workingDirectory
147 |
148 | /// URL to the project's root folder
149 | leturlObject=FileKit.workingDirectoryURL
150 |
151 |
Native Swift File Utilities
152 |
153 |
Note. As this is native Swift functionality you can use this without importing FileKit.
154 |
/// URL pointing to the current source file when it was compiled.
155 | letstringUrl=URL(fileURLWithPath:#file)
156 |
176 |
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/docs/docsets/FileKit.docset/Contents/Resources/Documents/js/jazzy.js:
--------------------------------------------------------------------------------
1 | window.jazzy = {'docset': false}
2 | if (typeof window.dash != 'undefined') {
3 | document.documentElement.className += ' dash'
4 | window.jazzy.docset = true
5 | }
6 | if (navigator.userAgent.match(/xcode/i)) {
7 | document.documentElement.className += ' xcode'
8 | window.jazzy.docset = true
9 | }
10 |
11 | // On doc load, toggle the URL hash discussion if present
12 | $(document).ready(function() {
13 | if (!window.jazzy.docset) {
14 | var linkToHash = $('a[href="' + window.location.hash +'"]');
15 | linkToHash.trigger("click");
16 | }
17 | });
18 |
19 | // On token click, toggle its discussion and animate token.marginLeft
20 | $(".token").click(function(event) {
21 | if (window.jazzy.docset) {
22 | return;
23 | }
24 | var link = $(this);
25 | var animationDuration = 300;
26 | $content = link.parent().parent().next();
27 | $content.slideToggle(animationDuration);
28 |
29 | // Keeps the document from jumping to the hash.
30 | var href = $(this).attr('href');
31 | if (history.pushState) {
32 | history.pushState({}, '', href);
33 | } else {
34 | location.hash = href;
35 | }
36 | event.preventDefault();
37 | });
38 |
39 | // Dumb down quotes within code blocks that delimit strings instead of quotations
40 | // https://github.com/realm/jazzy/issues/714
41 | $("code q").replaceWith(function () {
42 | return ["\"", $(this).contents(), "\""];
43 | });
44 |
--------------------------------------------------------------------------------
/docs/docsets/FileKit.docset/Contents/Resources/Documents/js/jazzy.search.js:
--------------------------------------------------------------------------------
1 | $(function(){
2 | var searchIndex = lunr(function() {
3 | this.ref('url');
4 | this.field('name');
5 | });
6 |
7 | var $typeahead = $('[data-typeahead]');
8 | var $form = $typeahead.parents('form');
9 | var searchURL = $form.attr('action');
10 |
11 | function displayTemplate(result) {
12 | return result.name;
13 | }
14 |
15 | function suggestionTemplate(result) {
16 | var t = '
';
17 | t += '' + result.name + '';
18 | if (result.parent_name) {
19 | t += '' + result.parent_name + '';
20 | }
21 | t += '
';
22 | return t;
23 | }
24 |
25 | $typeahead.one('focus', function() {
26 | $form.addClass('loading');
27 |
28 | $.getJSON(searchURL).then(function(searchData) {
29 | $.each(searchData, function (url, doc) {
30 | searchIndex.add({url: url, name: doc.name});
31 | });
32 |
33 | $typeahead.typeahead(
34 | {
35 | highlight: true,
36 | minLength: 3
37 | },
38 | {
39 | limit: 10,
40 | display: displayTemplate,
41 | templates: { suggestion: suggestionTemplate },
42 | source: function(query, sync) {
43 | var results = searchIndex.search(query).map(function(result) {
44 | var doc = searchData[result.ref];
45 | doc.url = result.ref;
46 | return doc;
47 | });
48 | sync(results);
49 | }
50 | }
51 | );
52 | $form.removeClass('loading');
53 | $typeahead.trigger('focus');
54 | });
55 | });
56 |
57 | var baseURL = searchURL.slice(0, -"search.json".length);
58 |
59 | $typeahead.on('typeahead:select', function(e, result) {
60 | window.location = baseURL + result.url;
61 | });
62 | });
63 |
--------------------------------------------------------------------------------
/docs/docsets/FileKit.docset/Contents/Resources/Documents/js/lunr.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.7.2
3 | * Copyright (C) 2016 Oliver Nightingale
4 | * @license MIT
5 | */
6 | !function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.7.2",t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),t.utils.asString=function(t){return void 0===t||null===t?"":t.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||delete this.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){return t in this.events},t.tokenizer=function(e){if(!arguments.length||null==e||void 0==e)return[];if(Array.isArray(e))return e.map(function(e){return t.utils.asString(e).toLowerCase()});var n=t.tokenizer.seperator||t.tokenizer.separator;return e.toString().trim().toLowerCase().split(n)},t.tokenizer.seperator=!1,t.tokenizer.separator=/[\s\-]+/,t.tokenizer.load=function(t){var e=this.registeredFunctions[t];if(!e)throw new Error("Cannot load un-registered function: "+t);return e},t.tokenizer.label="default",t.tokenizer.registeredFunctions={"default":t.tokenizer},t.tokenizer.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing tokenizer: "+n),e.label=n,this.registeredFunctions[n]=e},t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.registeredFunctions[e];if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);if(-1==i)throw new Error("Cannot find existingFn");i+=1,this._stack.splice(i,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);if(-1==i)throw new Error("Cannot find existingFn");this._stack.splice(i,0,n)},t.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);-1!=e&&this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(var e=[],n=t.length,i=this._stack.length,r=0;n>r;r++){for(var o=t[r],s=0;i>s&&(o=this._stack[s](o,r,t),void 0!==o&&""!==o);s++);void 0!==o&&""!==o&&e.push(o)}return e},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){this._magnitude=void 0;var i=this.list;if(!i)return this.list=new t.Vector.Node(e,n,i),this.length++;if(en.idx?n=n.next:(i+=e.val*n.val,e=e.next,n=n.next);return i},t.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){var t,e;for(t=0;t1;){if(o===t)return r;t>o&&(e=r),o>t&&(n=r),i=n-e,r=e+Math.floor(i/2),o=this.elements[r]}return o===t?r:-1},t.SortedSet.prototype.locationFor=function(t){for(var e=0,n=this.elements.length,i=n-e,r=e+Math.floor(i/2),o=this.elements[r];i>1;)t>o&&(e=r),o>t&&(n=r),i=n-e,r=e+Math.floor(i/2),o=this.elements[r];return o>t?r:t>o?r+1:void 0},t.SortedSet.prototype.intersect=function(e){for(var n=new t.SortedSet,i=0,r=0,o=this.length,s=e.length,a=this.elements,h=e.elements;;){if(i>o-1||r>s-1)break;a[i]!==h[r]?a[i]h[r]&&r++:(n.add(a[i]),i++,r++)}return n},t.SortedSet.prototype.clone=function(){var e=new t.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},t.SortedSet.prototype.union=function(t){var e,n,i;this.length>=t.length?(e=this,n=t):(e=t,n=this),i=e.clone();for(var r=0,o=n.toArray();rp;p++)c[p]===a&&d++;h+=d/f*l.boost}}this.tokenStore.add(a,{ref:o,tf:h})}n&&this.eventEmitter.emit("add",e,this)},t.Index.prototype.remove=function(t,e){var n=t[this._ref],e=void 0===e?!0:e;if(this.documentStore.has(n)){var i=this.documentStore.get(n);this.documentStore.remove(n),i.forEach(function(t){this.tokenStore.remove(t,n)},this),e&&this.eventEmitter.emit("remove",t,this)}},t.Index.prototype.update=function(t,e){var e=void 0===e?!0:e;this.remove(t,!1),this.add(t,!1),e&&this.eventEmitter.emit("update",t,this)},t.Index.prototype.idf=function(t){var e="@"+t;if(Object.prototype.hasOwnProperty.call(this._idfCache,e))return this._idfCache[e];var n=this.tokenStore.count(t),i=1;return n>0&&(i=1+Math.log(this.documentStore.length/n)),this._idfCache[e]=i},t.Index.prototype.search=function(e){var n=this.pipeline.run(this.tokenizerFn(e)),i=new t.Vector,r=[],o=this._fields.reduce(function(t,e){return t+e.boost},0),s=n.some(function(t){return this.tokenStore.has(t)},this);if(!s)return[];n.forEach(function(e,n,s){var a=1/s.length*this._fields.length*o,h=this,u=this.tokenStore.expand(e).reduce(function(n,r){var o=h.corpusTokens.indexOf(r),s=h.idf(r),u=1,l=new t.SortedSet;if(r!==e){var c=Math.max(3,r.length-e.length);u=1/Math.log(c)}o>-1&&i.insert(o,a*s*u);for(var f=h.tokenStore.get(r),d=Object.keys(f),p=d.length,v=0;p>v;v++)l.add(f[d[v]].ref);return n.union(l)},new t.SortedSet);r.push(u)},this);var a=r.reduce(function(t,e){return t.intersect(e)});return a.map(function(t){return{ref:t,score:i.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})},t.Index.prototype.documentVector=function(e){for(var n=this.documentStore.get(e),i=n.length,r=new t.Vector,o=0;i>o;o++){var s=n.elements[o],a=this.tokenStore.get(s)[e].tf,h=this.idf(s);r.insert(this.corpusTokens.indexOf(s),a*h)}return r},t.Index.prototype.toJSON=function(){return{version:t.version,fields:this._fields,ref:this._ref,tokenizer:this.tokenizerFn.label,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},t.Store=function(){this.store={},this.length=0},t.Store.load=function(e){var n=new this;return n.length=e.length,n.store=Object.keys(e.store).reduce(function(n,i){return n[i]=t.SortedSet.load(e.store[i]),n},{}),n},t.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},t.Store.prototype.get=function(t){return this.store[t]},t.Store.prototype.has=function(t){return t in this.store},t.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},t.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},t.stemmer=function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},e={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",r=n+"[^aeiouy]*",o=i+"[aeiou]*",s="^("+r+")?"+o+r,a="^("+r+")?"+o+r+"("+o+")?$",h="^("+r+")?"+o+r+o+r,u="^("+r+")?"+i,l=new RegExp(s),c=new RegExp(h),f=new RegExp(a),d=new RegExp(u),p=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,m=/^(.+?)(ed|ing)$/,y=/.$/,S=/(at|bl|iz)$/,w=new RegExp("([^aeiouylsz])\\1$"),k=new RegExp("^"+r+i+"[^aeiouwxy]$"),x=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,F=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,_=/^(.+?)(s|t)(ion)$/,z=/^(.+?)e$/,O=/ll$/,P=new RegExp("^"+r+i+"[^aeiouwxy]$"),T=function(n){var i,r,o,s,a,h,u;if(n.length<3)return n;if(o=n.substr(0,1),"y"==o&&(n=o.toUpperCase()+n.substr(1)),s=p,a=v,s.test(n)?n=n.replace(s,"$1$2"):a.test(n)&&(n=n.replace(a,"$1$2")),s=g,a=m,s.test(n)){var T=s.exec(n);s=l,s.test(T[1])&&(s=y,n=n.replace(s,""))}else if(a.test(n)){var T=a.exec(n);i=T[1],a=d,a.test(i)&&(n=i,a=S,h=w,u=k,a.test(n)?n+="e":h.test(n)?(s=y,n=n.replace(s,"")):u.test(n)&&(n+="e"))}if(s=x,s.test(n)){var T=s.exec(n);i=T[1],n=i+"i"}if(s=b,s.test(n)){var T=s.exec(n);i=T[1],r=T[2],s=l,s.test(i)&&(n=i+t[r])}if(s=E,s.test(n)){var T=s.exec(n);i=T[1],r=T[2],s=l,s.test(i)&&(n=i+e[r])}if(s=F,a=_,s.test(n)){var T=s.exec(n);i=T[1],s=c,s.test(i)&&(n=i)}else if(a.test(n)){var T=a.exec(n);i=T[1]+T[2],a=c,a.test(i)&&(n=i)}if(s=z,s.test(n)){var T=s.exec(n);i=T[1],s=c,a=f,h=P,(s.test(i)||a.test(i)&&!h.test(i))&&(n=i)}return s=O,a=c,s.test(n)&&a.test(n)&&(s=y,n=n.replace(s,"")),"y"==o&&(n=o.toLowerCase()+n.substr(1)),n};return T}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),t.generateStopWordFilter=function(t){var e=t.reduce(function(t,e){return t[e]=e,t},{});return function(t){return t&&e[t]!==t?t:void 0}},t.stopWordFilter=t.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),t.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),t.TokenStore=function(){this.root={docs:{}},this.length=0},t.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},t.TokenStore.prototype.add=function(t,e,n){var n=n||this.root,i=t.charAt(0),r=t.slice(1);return i in n||(n[i]={docs:{}}),0===r.length?(n[i].docs[e.ref]=e,void(this.length+=1)):this.add(r,e,n[i])},t.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,n=0;nThe absolute path to the folder containing the project executable.","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC19executableFolderURL10Foundation0E0VvpZ":{"name":"executableFolderURL","abstract":"
URL that points to the directory containing the project executable, or, if run from inside Xcode,","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC13executableURL10Foundation0D0VvpZ":{"name":"executableURL","abstract":"
Absolute path to the directory containing the Package.swift of the project (as determined by","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC16projectFolderURL10Foundation0E0VvpZ":{"name":"projectFolderURL","abstract":"
URL that points to the directory containing the Package.swift of the project (as determined","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC16workingDirectorySSvpZ":{"name":"workingDirectory","abstract":"
Provides the standardized working directory accounting for environmental changes.","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC19workingDirectoryURL10Foundation0E0VvpZ":{"name":"workingDirectoryURL","abstract":"
URL that points to the standardized working directory accounting for environmental changes.","parent_name":"FileKit"},"Classes/FileKit.html":{"name":"FileKit","abstract":"
Resolves commonly used paths, including the project, executable and working directories.
You will also need to import the Foundation package if you’re handling URLs:
108 |
importFoundation
109 |
110 |
Supported Paths
111 |
Path to Executable Folder
112 |
113 |
Points to the folder containing the project executable.
114 |
115 |
For example, when running an executable called MySwiftProject within Xcode the executable folder string would be /Users/username/MySwiftProject/.build/debug, when running the same project from the command line this would be /Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug.
Note, the executableURL will be different when running inside Xcode versus running from the command line.
127 | For example, when running an executable called MySwiftProject:
128 |
129 |
130 |
Running on the command line - file:///Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug/MySwiftProject
131 |
Running within Xcode - file:///Users/username/Library/Developer/Xcode/DerivedData/MySwiftProject-fjgfjmxrlbhzkhfmxdgeipylyeay/Build/Products/Debug/MySwiftProject.
132 |
133 |
Path to Project Folder
134 |
135 |
Points to the directory containing the Package.swift of the project (as determined by traversing up the directory structure starting at the directory containing the executable), or if no Package.swift is found then the directory containing the executable.
136 |
/// Absolute path to the project's root folder
137 | letstringUrl=FileKit.projectFolder
138 |
139 | /// URL to the project's root folder
140 | leturlObject=FileKit.projectFolderURL
141 |
142 |
Path to Working Directory
143 |
144 |
Provides the standardized working directory, while accounting for environmental changes. When running in Xcode, this returns the directory containing the Package.swift of the project, while outside Xcode it returns the current working directory.
145 |
/// Absolute path to the present working directory
146 | letstringUrl=FileKit.workingDirectory
147 |
148 | /// URL to the project's root folder
149 | leturlObject=FileKit.workingDirectoryURL
150 |
151 |
Native Swift File Utilities
152 |
153 |
Note. As this is native Swift functionality you can use this without importing FileKit.
154 |
/// URL pointing to the current source file when it was compiled.
155 | letstringUrl=URL(fileURLWithPath:#file)
156 |
176 |
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/docs/js/jazzy.js:
--------------------------------------------------------------------------------
1 | window.jazzy = {'docset': false}
2 | if (typeof window.dash != 'undefined') {
3 | document.documentElement.className += ' dash'
4 | window.jazzy.docset = true
5 | }
6 | if (navigator.userAgent.match(/xcode/i)) {
7 | document.documentElement.className += ' xcode'
8 | window.jazzy.docset = true
9 | }
10 |
11 | // On doc load, toggle the URL hash discussion if present
12 | $(document).ready(function() {
13 | if (!window.jazzy.docset) {
14 | var linkToHash = $('a[href="' + window.location.hash +'"]');
15 | linkToHash.trigger("click");
16 | }
17 | });
18 |
19 | // On token click, toggle its discussion and animate token.marginLeft
20 | $(".token").click(function(event) {
21 | if (window.jazzy.docset) {
22 | return;
23 | }
24 | var link = $(this);
25 | var animationDuration = 300;
26 | $content = link.parent().parent().next();
27 | $content.slideToggle(animationDuration);
28 |
29 | // Keeps the document from jumping to the hash.
30 | var href = $(this).attr('href');
31 | if (history.pushState) {
32 | history.pushState({}, '', href);
33 | } else {
34 | location.hash = href;
35 | }
36 | event.preventDefault();
37 | });
38 |
39 | // Dumb down quotes within code blocks that delimit strings instead of quotations
40 | // https://github.com/realm/jazzy/issues/714
41 | $("code q").replaceWith(function () {
42 | return ["\"", $(this).contents(), "\""];
43 | });
44 |
--------------------------------------------------------------------------------
/docs/js/jazzy.search.js:
--------------------------------------------------------------------------------
1 | $(function(){
2 | var searchIndex = lunr(function() {
3 | this.ref('url');
4 | this.field('name');
5 | });
6 |
7 | var $typeahead = $('[data-typeahead]');
8 | var $form = $typeahead.parents('form');
9 | var searchURL = $form.attr('action');
10 |
11 | function displayTemplate(result) {
12 | return result.name;
13 | }
14 |
15 | function suggestionTemplate(result) {
16 | var t = '
';
17 | t += '' + result.name + '';
18 | if (result.parent_name) {
19 | t += '' + result.parent_name + '';
20 | }
21 | t += '
';
22 | return t;
23 | }
24 |
25 | $typeahead.one('focus', function() {
26 | $form.addClass('loading');
27 |
28 | $.getJSON(searchURL).then(function(searchData) {
29 | $.each(searchData, function (url, doc) {
30 | searchIndex.add({url: url, name: doc.name});
31 | });
32 |
33 | $typeahead.typeahead(
34 | {
35 | highlight: true,
36 | minLength: 3
37 | },
38 | {
39 | limit: 10,
40 | display: displayTemplate,
41 | templates: { suggestion: suggestionTemplate },
42 | source: function(query, sync) {
43 | var results = searchIndex.search(query).map(function(result) {
44 | var doc = searchData[result.ref];
45 | doc.url = result.ref;
46 | return doc;
47 | });
48 | sync(results);
49 | }
50 | }
51 | );
52 | $form.removeClass('loading');
53 | $typeahead.trigger('focus');
54 | });
55 | });
56 |
57 | var baseURL = searchURL.slice(0, -"search.json".length);
58 |
59 | $typeahead.on('typeahead:select', function(e, result) {
60 | window.location = baseURL + result.url;
61 | });
62 | });
63 |
--------------------------------------------------------------------------------
/docs/js/lunr.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.7.2
3 | * Copyright (C) 2016 Oliver Nightingale
4 | * @license MIT
5 | */
6 | !function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.7.2",t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),t.utils.asString=function(t){return void 0===t||null===t?"":t.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||delete this.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){return t in this.events},t.tokenizer=function(e){if(!arguments.length||null==e||void 0==e)return[];if(Array.isArray(e))return e.map(function(e){return t.utils.asString(e).toLowerCase()});var n=t.tokenizer.seperator||t.tokenizer.separator;return e.toString().trim().toLowerCase().split(n)},t.tokenizer.seperator=!1,t.tokenizer.separator=/[\s\-]+/,t.tokenizer.load=function(t){var e=this.registeredFunctions[t];if(!e)throw new Error("Cannot load un-registered function: "+t);return e},t.tokenizer.label="default",t.tokenizer.registeredFunctions={"default":t.tokenizer},t.tokenizer.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing tokenizer: "+n),e.label=n,this.registeredFunctions[n]=e},t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.registeredFunctions[e];if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);if(-1==i)throw new Error("Cannot find existingFn");i+=1,this._stack.splice(i,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);if(-1==i)throw new Error("Cannot find existingFn");this._stack.splice(i,0,n)},t.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);-1!=e&&this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(var e=[],n=t.length,i=this._stack.length,r=0;n>r;r++){for(var o=t[r],s=0;i>s&&(o=this._stack[s](o,r,t),void 0!==o&&""!==o);s++);void 0!==o&&""!==o&&e.push(o)}return e},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){this._magnitude=void 0;var i=this.list;if(!i)return this.list=new t.Vector.Node(e,n,i),this.length++;if(en.idx?n=n.next:(i+=e.val*n.val,e=e.next,n=n.next);return i},t.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){var t,e;for(t=0;t1;){if(o===t)return r;t>o&&(e=r),o>t&&(n=r),i=n-e,r=e+Math.floor(i/2),o=this.elements[r]}return o===t?r:-1},t.SortedSet.prototype.locationFor=function(t){for(var e=0,n=this.elements.length,i=n-e,r=e+Math.floor(i/2),o=this.elements[r];i>1;)t>o&&(e=r),o>t&&(n=r),i=n-e,r=e+Math.floor(i/2),o=this.elements[r];return o>t?r:t>o?r+1:void 0},t.SortedSet.prototype.intersect=function(e){for(var n=new t.SortedSet,i=0,r=0,o=this.length,s=e.length,a=this.elements,h=e.elements;;){if(i>o-1||r>s-1)break;a[i]!==h[r]?a[i]h[r]&&r++:(n.add(a[i]),i++,r++)}return n},t.SortedSet.prototype.clone=function(){var e=new t.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},t.SortedSet.prototype.union=function(t){var e,n,i;this.length>=t.length?(e=this,n=t):(e=t,n=this),i=e.clone();for(var r=0,o=n.toArray();rp;p++)c[p]===a&&d++;h+=d/f*l.boost}}this.tokenStore.add(a,{ref:o,tf:h})}n&&this.eventEmitter.emit("add",e,this)},t.Index.prototype.remove=function(t,e){var n=t[this._ref],e=void 0===e?!0:e;if(this.documentStore.has(n)){var i=this.documentStore.get(n);this.documentStore.remove(n),i.forEach(function(t){this.tokenStore.remove(t,n)},this),e&&this.eventEmitter.emit("remove",t,this)}},t.Index.prototype.update=function(t,e){var e=void 0===e?!0:e;this.remove(t,!1),this.add(t,!1),e&&this.eventEmitter.emit("update",t,this)},t.Index.prototype.idf=function(t){var e="@"+t;if(Object.prototype.hasOwnProperty.call(this._idfCache,e))return this._idfCache[e];var n=this.tokenStore.count(t),i=1;return n>0&&(i=1+Math.log(this.documentStore.length/n)),this._idfCache[e]=i},t.Index.prototype.search=function(e){var n=this.pipeline.run(this.tokenizerFn(e)),i=new t.Vector,r=[],o=this._fields.reduce(function(t,e){return t+e.boost},0),s=n.some(function(t){return this.tokenStore.has(t)},this);if(!s)return[];n.forEach(function(e,n,s){var a=1/s.length*this._fields.length*o,h=this,u=this.tokenStore.expand(e).reduce(function(n,r){var o=h.corpusTokens.indexOf(r),s=h.idf(r),u=1,l=new t.SortedSet;if(r!==e){var c=Math.max(3,r.length-e.length);u=1/Math.log(c)}o>-1&&i.insert(o,a*s*u);for(var f=h.tokenStore.get(r),d=Object.keys(f),p=d.length,v=0;p>v;v++)l.add(f[d[v]].ref);return n.union(l)},new t.SortedSet);r.push(u)},this);var a=r.reduce(function(t,e){return t.intersect(e)});return a.map(function(t){return{ref:t,score:i.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})},t.Index.prototype.documentVector=function(e){for(var n=this.documentStore.get(e),i=n.length,r=new t.Vector,o=0;i>o;o++){var s=n.elements[o],a=this.tokenStore.get(s)[e].tf,h=this.idf(s);r.insert(this.corpusTokens.indexOf(s),a*h)}return r},t.Index.prototype.toJSON=function(){return{version:t.version,fields:this._fields,ref:this._ref,tokenizer:this.tokenizerFn.label,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},t.Store=function(){this.store={},this.length=0},t.Store.load=function(e){var n=new this;return n.length=e.length,n.store=Object.keys(e.store).reduce(function(n,i){return n[i]=t.SortedSet.load(e.store[i]),n},{}),n},t.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},t.Store.prototype.get=function(t){return this.store[t]},t.Store.prototype.has=function(t){return t in this.store},t.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},t.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},t.stemmer=function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},e={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",r=n+"[^aeiouy]*",o=i+"[aeiou]*",s="^("+r+")?"+o+r,a="^("+r+")?"+o+r+"("+o+")?$",h="^("+r+")?"+o+r+o+r,u="^("+r+")?"+i,l=new RegExp(s),c=new RegExp(h),f=new RegExp(a),d=new RegExp(u),p=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,m=/^(.+?)(ed|ing)$/,y=/.$/,S=/(at|bl|iz)$/,w=new RegExp("([^aeiouylsz])\\1$"),k=new RegExp("^"+r+i+"[^aeiouwxy]$"),x=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,F=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,_=/^(.+?)(s|t)(ion)$/,z=/^(.+?)e$/,O=/ll$/,P=new RegExp("^"+r+i+"[^aeiouwxy]$"),T=function(n){var i,r,o,s,a,h,u;if(n.length<3)return n;if(o=n.substr(0,1),"y"==o&&(n=o.toUpperCase()+n.substr(1)),s=p,a=v,s.test(n)?n=n.replace(s,"$1$2"):a.test(n)&&(n=n.replace(a,"$1$2")),s=g,a=m,s.test(n)){var T=s.exec(n);s=l,s.test(T[1])&&(s=y,n=n.replace(s,""))}else if(a.test(n)){var T=a.exec(n);i=T[1],a=d,a.test(i)&&(n=i,a=S,h=w,u=k,a.test(n)?n+="e":h.test(n)?(s=y,n=n.replace(s,"")):u.test(n)&&(n+="e"))}if(s=x,s.test(n)){var T=s.exec(n);i=T[1],n=i+"i"}if(s=b,s.test(n)){var T=s.exec(n);i=T[1],r=T[2],s=l,s.test(i)&&(n=i+t[r])}if(s=E,s.test(n)){var T=s.exec(n);i=T[1],r=T[2],s=l,s.test(i)&&(n=i+e[r])}if(s=F,a=_,s.test(n)){var T=s.exec(n);i=T[1],s=c,s.test(i)&&(n=i)}else if(a.test(n)){var T=a.exec(n);i=T[1]+T[2],a=c,a.test(i)&&(n=i)}if(s=z,s.test(n)){var T=s.exec(n);i=T[1],s=c,a=f,h=P,(s.test(i)||a.test(i)&&!h.test(i))&&(n=i)}return s=O,a=c,s.test(n)&&a.test(n)&&(s=y,n=n.replace(s,"")),"y"==o&&(n=o.toLowerCase()+n.substr(1)),n};return T}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),t.generateStopWordFilter=function(t){var e=t.reduce(function(t,e){return t[e]=e,t},{});return function(t){return t&&e[t]!==t?t:void 0}},t.stopWordFilter=t.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),t.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),t.TokenStore=function(){this.root={docs:{}},this.length=0},t.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},t.TokenStore.prototype.add=function(t,e,n){var n=n||this.root,i=t.charAt(0),r=t.slice(1);return i in n||(n[i]={docs:{}}),0===r.length?(n[i].docs[e.ref]=e,void(this.length+=1)):this.add(r,e,n[i])},t.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,n=0;nThe absolute path to the folder containing the project executable.","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC19executableFolderURL10Foundation0E0VvpZ":{"name":"executableFolderURL","abstract":"
URL that points to the directory containing the project executable, or, if run from inside Xcode,","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC13executableURL10Foundation0D0VvpZ":{"name":"executableURL","abstract":"
Absolute path to the directory containing the Package.swift of the project (as determined by","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC16projectFolderURL10Foundation0E0VvpZ":{"name":"projectFolderURL","abstract":"
URL that points to the directory containing the Package.swift of the project (as determined","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC16workingDirectorySSvpZ":{"name":"workingDirectory","abstract":"
Provides the standardized working directory accounting for environmental changes.","parent_name":"FileKit"},"Classes/FileKit.html#/s:7FileKitAAC19workingDirectoryURL10Foundation0E0VvpZ":{"name":"workingDirectoryURL","abstract":"
URL that points to the standardized working directory accounting for environmental changes.","parent_name":"FileKit"},"Classes/FileKit.html":{"name":"FileKit","abstract":"
Resolves commonly used paths, including the project, executable and working directories.