-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Postpone the cleanup of temporary files
- Loading branch information
Showing
5 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
WhatCopiedMac/Modules/Sources/FoundationExtensions/FileManager+Extension.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// FileManager+Extension.swift | ||
// WhatCopied | ||
// | ||
// Created by cyan on 2024/12/11. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension FileManager { | ||
func directoryExists(at url: URL) -> Bool { | ||
var isDirectory: ObjCBool = false | ||
let fileExists = fileExists(atPath: url.path, isDirectory: &isDirectory) | ||
return fileExists && isDirectory.boolValue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// URL+Extension.swift | ||
// WhatCopied | ||
// | ||
// Created by cyan on 2024/12/11. | ||
// | ||
|
||
import Foundation | ||
|
||
extension URL { | ||
static var previewingDirectory: URL { | ||
let directory = temporaryDirectory.appendingPathComponent("QuickLook") | ||
let fileManager = FileManager.default | ||
|
||
if !fileManager.directoryExists(at: directory) { | ||
do { | ||
try fileManager.createDirectory(at: directory, withIntermediateDirectories: false) | ||
} catch { | ||
Logger.log(.error, "Failed to create previewing directory: \(error.localizedDescription)") | ||
} | ||
} | ||
|
||
return directory | ||
} | ||
} |