Skip to content

writeFileData does not check if parent directory exists #6

@martingrzzler

Description

@martingrzzler

This line failed because there was no entry for the parent directory.

try Data().write(to: fileURL)

Adding this code before made it work:

let parentDirPath = fileURL.path.split(separator: "/").dropLast().joined(separator: "/")
if !FileManager.default.fileExists(atPath: parentDirPath) {
     try FileManager.default.createDirectory(atPath: parentDirPath, withIntermediateDirectories: true)
}     

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions