Delete some unused code.

This commit is contained in:
Brent Simmons
2025-02-02 10:57:26 -08:00
parent 510f0b20ec
commit 57cf732f5a
5 changed files with 8 additions and 91 deletions

View File

@@ -26,35 +26,6 @@ public extension FileManager {
return false
}
/// Copies files from one folder to another, overwriting any existing files with the same name.
///
/// - Parameters:
/// - source: The path of the folder from which to copy files.
/// - destination: The path to the folder at which to place the copied files.
///
/// - Note: This function does not copy files whose names begin with a period.
func copyFiles(fromFolder source: String, toFolder destination: String) throws {
assert(isFolder(atPath: source))
assert(isFolder(atPath: destination))
let sourceURL = URL(fileURLWithPath: source)
let destinationURL = URL(fileURLWithPath: destination)
let filenames = try self.contentsOfDirectory(atPath: source)
for oneFilename in filenames {
if oneFilename.hasPrefix(".") {
continue
}
let sourceFile = sourceURL.appendingPathComponent(oneFilename)
let destinationFile = destinationURL.appendingPathComponent(oneFilename)
try copyFile(atPath: sourceFile.path, toPath: destinationFile.path, overwriting: true)
}
}
/// Retrieve the names of files contained in a folder.
///
/// - Parameter folder: The path to the folder whose contents to retrieve.
@@ -85,27 +56,4 @@ public extension FileManager {
let url = URL(fileURLWithPath: folder)
return filenames.map { url.appendingPathComponent($0).path }
}
}
private extension FileManager {
/// Copies a single file, possibly overwriting any existing file.
///
/// - Parameters:
/// - source: The source path.
/// - destination: The destination path.
/// - overwriting: `true` if an existing file at `destination` should be overwritten.
func copyFile(atPath source: String, toPath destination: String, overwriting: Bool) throws {
assert(fileExists(atPath: source))
if fileExists(atPath: destination) {
if overwriting {
try removeItem(atPath: destination)
}
}
try copyItem(atPath: source, toPath: destination)
}
}

View File

@@ -1,25 +0,0 @@
//
// RSScreen.swift
// RSCore
//
// Created by Maurice Parker on 4/11/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
#if os(macOS)
import AppKit
public class RSScreen {
public static var maxScreenScale = CGFloat(2)
}
#endif
#if os(iOS)
import UIKit
public class RSScreen {
public static var maxScreenScale = CGFloat(3)
}
#endif

View File

@@ -10,15 +10,6 @@ import Foundation
public extension Set {
func anyObjectPassingTest( _ test: (Element) -> Bool) -> Element? {
guard let index = self.firstIndex(where: test) else {
return nil
}
return self[index]
}
func anyObject() -> Element? {
if self.isEmpty {

View File

@@ -18,10 +18,6 @@ public extension String {
return "<a href=\"\(link)\">\(self)</a>"
}
func htmlBySurroundingWithTag(_ tag: String) -> String {
return "<\(tag)>\(self)</\(tag)>"
}
static func htmlWithLink(_ link: String) -> String {
return link.htmlByAddingLink(link)
}

View File

@@ -17,12 +17,19 @@ extension RSImage {
static let maxIconSize = 48
#if os(macOS)
static let maxScreenScale = CGFloat(2)
#elseif os(iOS)
static let maxScreenScale = CGFloat(3)
#endif
static func scaledForIcon(_ data: Data, imageResultBlock: @escaping ImageResultBlock) {
IconScalerQueue.shared.scaledForIcon(data, imageResultBlock)
}
static func scaledForIcon(_ data: Data) -> RSImage? {
let scaledMaxPixelSize = Int(ceil(CGFloat(RSImage.maxIconSize) * RSScreen.maxScreenScale))
let scaledMaxPixelSize = Int(ceil(CGFloat(RSImage.maxIconSize) * Self.maxScreenScale))
guard var cgImage = RSImage.scaleImage(data, maxPixelSize: scaledMaxPixelSize) else {
return nil
}