https://github.com/davidthorn/filemanagerextensions
https://github.com/davidthorn/filemanagerextensions
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/davidthorn/filemanagerextensions
- Owner: davidthorn
- License: mit
- Created: 2018-01-17T04:19:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-17T06:44:07.000Z (over 8 years ago)
- Last Synced: 2025-06-21T10:03:29.917Z (12 months ago)
- Language: Swift
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FileManagerExtensions
I created this package because the FileManager itself is too complicated and I always forgot which methods need to be called etc.
File management should be a simple thing and as easy as writing a terminal command like touch.
## Extensions
### homeDirectory
```swift
extension FileManager {
/// Returns the users home directory path
///
/// - :Returns String
public var homeDirectory: String
}
```
## mkdir
```swift
extension FileManager {
/// attempts to make the directory at the path name provided
///
/// - : Parameter path: The path which should be used to create the directory
/// - : Returns Bool true if directory has been created, false if not
public func mkdir(path name: String ) -> Bool
}
```
## convertPathIncludingTilde
```swift
extension FileManager {
/// Converts the tilde (~) if provided to the full path
///
/// - Parameter using: the path to the file which should be converted to an absolute strng
/// - Returns: A new string with the tilde remove if was present else the original string
public func convertPathIncludingTilde(using relativePath: String ) -> String
}
```
## tilde
```swift
extension String {
/// returns an tilde in the string if it has an index of 0
///
/// - :Returns tilde character as a string
public var tilde: String?
}
```
## FileManager.createFile
```swift
extension FileManager {
/// writes the contents of the data to the filename
///
/// - Parameter: with the name of the filename
/// - Parameter: using data
/// - Returns: true if the data has been written or false for all other reasons
public func createFile(with filename: String, using data: Data? = nil ) -> Bool
}
```
## String.createFile
```swift
extension String {
/// writes the contents of the string to the filename
///
/// - Parameter: with the name of the filename
/// - Returns: true if the data has been written or false for all other reasons
public func createFile(with filename: String ) -> Bool
}
```
## touch
```swift
/// writes the contents of the string to the filename
///
/// - Parameter: filename the name of the filename
/// - Returns: true if the data has been written or false for all other reasons
func touch(filename: String) -> Bool
```
## String.touch
```swift
extension String {
/// creates a file using the filename
///
/// The filename can be either relative using the ~
/// The tilde will be automatically converted to use its absolute path
///
/// - Parameter: filename the name of the filename
/// - Returns: true if the file has been created otherwise false
public func touch(filename: String ) -> Bool
}
```