-
-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1607 from Provenance-Emu/feature/nitotv
Add nitotv methods for tvOS
- Loading branch information
Showing
5 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
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,52 @@ | ||
// | ||
// PVAppDelegate+NitoTV.swift | ||
// ProvenanceTV | ||
// | ||
// Created by Joseph Mattiello on 10/5/21. | ||
// Copyright © 2021 Provenance Emu. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
import PVSupport | ||
|
||
@objc | ||
extension PVAppDelegate { | ||
public func importFile(atURL url: URL) { | ||
|
||
let man = FileManager.default | ||
ILOG("[Provenance] host: \(url.host ?? "nil") path: \(url.path)") | ||
let cache = uploadDirectory | ||
do { | ||
let attrs = try man.attributesOfItem(atPath: cache.path) | ||
ILOG("[Provenance] cache attrs: \(attrs), cache path: \(cache)") | ||
let last = url.lastPathComponent | ||
let newPath = cache.appendingPathComponent(last) | ||
let originalPath = url | ||
try man.copyItem(at: originalPath, to: newPath) | ||
} catch { | ||
ELOG("\(error.localizedDescription)") | ||
} | ||
} | ||
|
||
var uploadDirectory: URL { | ||
let man = FileManager.default | ||
let paths = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true) | ||
let first: URL = URL(string: paths.first!)! | ||
let cache: URL = first.appendingPathComponent("Imports") | ||
let path = cache.path | ||
if !man.fileExists(atPath: path) { | ||
WLOG("this path wasnt found; \(cache)") | ||
let folderAttrs: [FileAttributeKey: Any] = [ | ||
.groupOwnerAccountName: "staff", | ||
.ownerAccountName: "mobile" | ||
] | ||
do { | ||
try man.createDirectory(at: cache, withIntermediateDirectories: true, attributes: folderAttrs) | ||
} catch { | ||
ELOG("\(error.localizedDescription)") | ||
} | ||
} | ||
return cache | ||
} | ||
} |
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