JohnSundell / Files

A nicer way to handle files & folders in Swift
MIT License
2.53k stars 182 forks source link

Proposal for subclassing Folder #63

Closed ghost closed 6 years ago

ghost commented 6 years ago

When setting up a permanent directory structure for an App, it might be good to create dedicated subclasses of Folder for frequent use. Could the following code be inside a failable initialiser?

var rulesFolder: Folder {
    let folder = try! Folder(path: FileSystem().homeFolder.path)
    let documents = try! folder.subfolder(named: "Documents")
    return try! documents.createSubfolderIfNeeded(withName: "Rules")
}

RulesFolder.swift

init?() {
    do {
        // self = 
    } catch {
        return nil
    }
}
clayellis commented 6 years ago

Why would Folder need to be subclassed to gain this functionality? Seems like this is a "problem" to be solved by the app itself by way of a DirectoryManager or a singleton.

ghost commented 6 years ago

Hi @clayellis

No functionality is gained in this proposal. Which is an interesting point to make in and of itself.

I'm not feeling it anymore.