It is a wrapper around the Apple FileManager class for managing the file system in object format.
- Unit tests
- CI
- Build iOS sample
- Build macOS sample
- Launch unit tests
- Build package
- Swiftlint
- Implement device class
- Test on tvOS
- Add logger
No dependency is necessary.
Nowaday we only support Swift Package Manager
. You can use build-in UI tool for XCode with this search words: Kelvas09/KVFileKit
or you can add it directyl with this following command :
.package(url: "https://github.com/Kelvas09/KVFileKit.git", from: "1.0.0")
It is very easy to get started with KVFileKit
. To do so, you just have to create a new instance of the FileSystem
class with an instance of the FileManager
as parameter:
let fileManager = FileManager.default
let fileSystem = FileSystem(fileManager: fileManager)
The FileSystem
class allows to retrieve a file or a folder from its URL:
guard let directory = fileSystem.getDirectory(from: directoryUrl) else { return }
...
guard let file = fileSystem.getFile(from: directoryUrl) else { return }
...
In case the file or directory does not exist, you will get a nil return.
It is possible to retrieve the first level of the tree directly with the FileSystem
class and a URL. To continue to go down the tree, you will need to see the entries
property of each folder.
The classes representing the directories and files do not have a state, so each time you ask for the tree structure or the reading of a file, it is done on the disk in order to avoid the changes done by another application.
Each folder can create files and subfolders from a simple name :
guard let directory = fileSystem.getDirectory(from: directoryUrl) else { return }
do {
try directory.createFile(with: "myFile", ext: "txt")
try directory.createDirectory(with: "myDirectory")
} catch {
print("Oops! Impossible to create file or folder")
}
You can access to samples projects on folder Samples