mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2024-12-13 09:07:16 +01:00
29 lines
915 B
Swift
29 lines
915 B
Swift
//
|
|
// FileManager.swift
|
|
//
|
|
//
|
|
// Created by MainasuK on 2022-1-15.
|
|
//
|
|
|
|
import os.log
|
|
import Foundation
|
|
|
|
extension FileManager {
|
|
static let logger = Logger(subsystem: "FileManager", category: "File")
|
|
|
|
public func createTemporaryFileURL(
|
|
filename: String,
|
|
pathExtension: String
|
|
) throws -> URL {
|
|
let tempDirectoryURL = FileManager.default.temporaryDirectory
|
|
let fileURL = tempDirectoryURL
|
|
.appendingPathComponent(filename)
|
|
.appendingPathExtension(pathExtension)
|
|
try FileManager.default.createDirectory(at: tempDirectoryURL, withIntermediateDirectories: true, attributes: nil)
|
|
|
|
Self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): create temporary file at: \(fileURL.debugDescription)")
|
|
|
|
return fileURL
|
|
}
|
|
}
|