Skip to content

Commit b3fade3

Browse files
committed
[feat]: warnings removal
1 parent 93a3541 commit b3fade3

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed

Sources/ScriptToolkit/FileExtension.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftShell
1111

1212
public extension File {
1313

14-
public func nameWithSuffix(_ suffix: String) -> String {
14+
func nameWithSuffix(_ suffix: String) -> String {
1515
if let unwrappedExtension = `extension` {
1616
return nameExcludingExtension + suffix + "." + unwrappedExtension
1717
}
@@ -23,7 +23,7 @@ public extension File {
2323
////////////////////////////////////////////////////////////////////////////////
2424
// MARK: - Duplication
2525

26-
@discardableResult public func createDuplicate(withName newName: String, keepExtension: Bool = true, overwrite: Bool = true) throws -> File? {
26+
@discardableResult func createDuplicate(withName newName: String, keepExtension: Bool = true, overwrite: Bool = true) throws -> File? {
2727
if !overwrite && FileManager.default.fileExists(atPath: newName) { return nil }
2828

2929
guard let parent = parent else {
@@ -55,7 +55,7 @@ public extension File {
5555
////////////////////////////////////////////////////////////////////////////////
5656
// MARK: - Modification date
5757

58-
public func modificationDate() throws -> Date {
58+
func modificationDate() throws -> Date {
5959

6060
let fileAttributes = try FileManager.default.attributesOfItem(atPath: path) as [FileAttributeKey: Any]
6161
let modificationDate = fileAttributes[.modificationDate] as! Date
@@ -66,7 +66,7 @@ public extension File {
6666
////////////////////////////////////////////////////////////////////////////////
6767
// MARK: - Tag file
6868

69-
public func tag(copy: Bool) throws {
69+
func tag(copy: Bool) throws {
7070
let date = try modificationDate()
7171
let suffix = ScriptToolkit.dateFormatter.string(from: date)
7272
for letter in "abcdefghijklmnopqrstuvwxyz" {
@@ -123,13 +123,13 @@ public extension File {
123123
////////////////////////////////////////////////////////////////////////////////
124124
// MARK: - Resize image
125125

126-
@discardableResult public func resizeImage(newName: String, size: CGSize, overwrite: Bool = true) throws -> File {
126+
@discardableResult func resizeImage(newName: String, size: CGSize, overwrite: Bool = true) throws -> File {
127127
if !overwrite && FileManager.default.fileExists(atPath: newName) { return try File(path: newName) }
128128
run(ScriptToolkit.convertPath, path, "-resize", "\(Int(size.width))x\(Int(size.height))",newName)
129129
return try File(path: newName)
130130
}
131131

132-
public func resizeAt123x(width: Int, height: Int, outputDir: Folder, overwrite: Bool = true) throws {
132+
func resizeAt123x(width: Int, height: Int, outputDir: Folder, overwrite: Bool = true) throws {
133133
print(name)
134134

135135
let res1name = outputDir.path.appendingPathComponent(path: name)
@@ -145,7 +145,7 @@ public extension File {
145145
////////////////////////////////////////////////////////////////////////////////
146146
// MARK: - Audio Processing
147147

148-
@discardableResult public func slowDownAudio(newName: String, percent: Float, overwrite: Bool = true) throws -> File {
148+
@discardableResult func slowDownAudio(newName: String, percent: Float, overwrite: Bool = true) throws -> File {
149149
if FileManager.default.fileExists(atPath: newName) {
150150
if !overwrite { return try File(path: newName) }
151151
try FileManager.default.removeItem(atPath: newName)
@@ -155,7 +155,7 @@ public extension File {
155155
return try File(path: newName)
156156
}
157157

158-
@discardableResult public func convertToWav(newName: String, overwrite: Bool = true) throws -> File {
158+
@discardableResult func convertToWav(newName: String, overwrite: Bool = true) throws -> File {
159159
if FileManager.default.fileExists(atPath: newName) {
160160
if !overwrite { return try File(path: newName) }
161161
try FileManager.default.removeItem(atPath: newName)
@@ -165,7 +165,7 @@ public extension File {
165165
return try File(path: newName)
166166
}
167167

168-
@discardableResult public func normalizeSampleRate(newName: String, overwrite: Bool = true) throws -> File {
168+
@discardableResult func normalizeSampleRate(newName: String, overwrite: Bool = true) throws -> File {
169169
if FileManager.default.fileExists(atPath: newName) {
170170
if !overwrite { return try File(path: newName) }
171171
try FileManager.default.removeItem(atPath: newName)
@@ -175,7 +175,7 @@ public extension File {
175175
return try File(path: newName)
176176
}
177177

178-
@discardableResult public func convertToM4A(newName: String, overwrite: Bool = true) throws -> File {
178+
@discardableResult func convertToM4A(newName: String, overwrite: Bool = true) throws -> File {
179179
if FileManager.default.fileExists(atPath: newName) {
180180
if !overwrite { return try File(path: newName) }
181181
try FileManager.default.removeItem(atPath: newName)
@@ -185,13 +185,13 @@ public extension File {
185185
return try File(path: newName)
186186
}
187187

188-
@discardableResult public func addSilence(newName: String, overwrite: Bool = true) throws -> File {
188+
@discardableResult func addSilence(newName: String, overwrite: Bool = true) throws -> File {
189189
if FileManager.default.fileExists(atPath: newName) {
190190
if !overwrite { return try File(path: newName) }
191191
try FileManager.default.removeItem(atPath: newName)
192192
}
193193

194-
let result = runAndDebug(ScriptToolkit.soxPath, ScriptToolkit.silenceFilePath, path, newName)
194+
runAndDebug(ScriptToolkit.soxPath, ScriptToolkit.silenceFilePath, path, newName)
195195
return try File(path: newName)
196196
}
197197

@@ -259,7 +259,7 @@ public extension File {
259259
////////////////////////////////////////////////////////////////////////////////
260260
// MARK: - Video Processing
261261

262-
@discardableResult public func reduceVideo(newName: String, overwrite: Bool = true) throws -> File {
262+
@discardableResult func reduceVideo(newName: String, overwrite: Bool = true) throws -> File {
263263
if FileManager.default.fileExists(atPath: newName) {
264264
if !overwrite { return try File(path: newName) }
265265
try FileManager.default.removeItem(atPath: newName)
@@ -272,7 +272,7 @@ public extension File {
272272
////////////////////////////////////////////////////////////////////////////////
273273
// MARK: - PDF
274274

275-
@discardableResult public func cropPDF(newName: String, insets: NSEdgeInsets, overwrite: Bool = true) throws -> File {
275+
@discardableResult func cropPDF(newName: String, insets: NSEdgeInsets, overwrite: Bool = true) throws -> File {
276276
if FileManager.default.fileExists(atPath: newName) {
277277
if !overwrite { return try File(path: newName) }
278278
try FileManager.default.removeItem(atPath: newName)

Sources/ScriptToolkit/FolderExtension.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftShell
1111

1212
public extension Folder {
1313

14-
@discardableResult public func createDuplicate(withName newName: String, keepExtension: Bool = true) throws -> Folder {
14+
@discardableResult func createDuplicate(withName newName: String, keepExtension: Bool = true) throws -> Folder {
1515
guard let parent = parent else {
1616
throw OperationError.renameFailed(self)
1717
}
@@ -43,7 +43,7 @@ public extension Folder {
4343
////////////////////////////////////////////////////////////////////////////////
4444
// MARK: - Modification date
4545

46-
public func modificationDate() throws -> Date {
46+
func modificationDate() throws -> Date {
4747

4848
let fileAttributes = try FileManager.default.attributesOfItem(atPath: path) as [FileAttributeKey: Any]
4949
let modificationDate = fileAttributes[.modificationDate] as! Date
@@ -54,7 +54,7 @@ public extension Folder {
5454
////////////////////////////////////////////////////////////////////////////////
5555
// MARK: - Tag folder
5656

57-
public func tag(copy: Bool) throws {
57+
func tag(copy: Bool) throws {
5858
let date = try modificationDate()
5959
let suffix = ScriptToolkit.dateFormatter.string(from: date)
6060
for letter in "abcdefghijklmnopqrstuvwxyz" {
@@ -82,7 +82,7 @@ public extension Folder {
8282
////////////////////////////////////////////////////////////////////////////////
8383
// MARK: - Flatten folder structure
8484

85-
public func flattenFolderStructure(outputDir: String, move: Bool, overwrite: Bool = true) throws {
85+
func flattenFolderStructure(outputDir: String, move: Bool, overwrite: Bool = true) throws {
8686
let outputFolder = try Folder(path: outputDir)
8787

8888
let inputFolderPath = path
@@ -110,7 +110,7 @@ public extension Folder {
110110
////////////////////////////////////////////////////////////////////////////////
111111
// MARK: - Sort Photos
112112

113-
public func exifTool(byCameraModel: Bool, processM4V: Bool) throws {
113+
func exifTool(byCameraModel: Bool, processM4V: Bool) throws {
114114
let inputFolder = try Folder(path: path)
115115

116116
print("📷 Processing EXIFtool...")
@@ -169,7 +169,7 @@ public extension Folder {
169169
}
170170
}
171171

172-
public func organizePhotos() throws {
172+
func organizePhotos() throws {
173173
print("📂 Organizing...")
174174

175175
var folderRecords = [(Folder, [Int])]()
@@ -203,7 +203,7 @@ public extension Folder {
203203
////////////////////////////////////////////////////////////////////////////////
204204
// MARK: - Remove Empty Directories
205205

206-
public func removeEmptyDirectories() throws {
206+
func removeEmptyDirectories() throws {
207207
for subfolder in subfolders {
208208
try subfolder.removeEmptyDirectories()
209209
}
@@ -217,7 +217,7 @@ public extension Folder {
217217
////////////////////////////////////////////////////////////////////////////////
218218
// MARK: - Find files
219219

220-
public func findFirstFile(name: String) -> File? {
220+
func findFirstFile(name: String) -> File? {
221221
for file in makeFileSequence(recursive: true) {
222222
if file.name == name {
223223
return file
@@ -226,7 +226,7 @@ public extension Folder {
226226
return nil
227227
}
228228

229-
public func findFiles(name: String) -> [File] {
229+
func findFiles(name: String) -> [File] {
230230
var foundFiles = [File]()
231231
for file in makeFileSequence(recursive: true) {
232232
if file.name == name {
@@ -236,7 +236,7 @@ public extension Folder {
236236
return foundFiles
237237
}
238238

239-
public func findFiles(regex: String) -> [File] {
239+
func findFiles(regex: String) -> [File] {
240240
var foundFiles = [File]()
241241
for file in makeFileSequence(recursive: true) {
242242
if !matches(for: regex, in: file.name).isEmpty {
@@ -249,7 +249,7 @@ public extension Folder {
249249
////////////////////////////////////////////////////////////////////////////////
250250
// MARK: - Find folders
251251

252-
public func findFirstFolder(name: String) -> Folder? {
252+
func findFirstFolder(name: String) -> Folder? {
253253
for folder in makeSubfolderSequence(recursive: true) {
254254
if folder.name == name {
255255
return folder
@@ -258,7 +258,7 @@ public extension Folder {
258258
return nil
259259
}
260260

261-
public func findFolders(name: String) -> [Folder] {
261+
func findFolders(name: String) -> [Folder] {
262262
var foundFolders = [Folder]()
263263
for folder in makeSubfolderSequence(recursive: true) {
264264
if folder.name == name {
@@ -268,7 +268,7 @@ public extension Folder {
268268
return foundFolders
269269
}
270270

271-
public func findFolders(regex: String) -> [Folder] {
271+
func findFolders(regex: String) -> [Folder] {
272272
var foundFolders = [Folder]()
273273
for folder in makeSubfolderSequence(recursive: true) {
274274
if !matches(for: regex, in: folder.name).isEmpty {

Sources/ScriptToolkit/String+Paths.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ import Foundation
99

1010
public extension String {
1111

12-
public var lastPathComponent: String {
12+
var lastPathComponent: String {
1313
return (self as NSString).lastPathComponent
1414
}
1515

16-
public var pathExtension: String {
16+
var pathExtension: String {
1717
return (self as NSString).pathExtension
1818
}
1919

20-
public var deletingLastPathComponent: String {
20+
var deletingLastPathComponent: String {
2121
return (self as NSString).deletingLastPathComponent
2222
}
2323

24-
public var deletingPathExtension: String {
24+
var deletingPathExtension: String {
2525
return (self as NSString).deletingPathExtension
2626
}
2727

28-
public var pathComponents: [String] {
28+
var pathComponents: [String] {
2929
return (self as NSString).pathComponents
3030
}
3131

32-
public func appendingPathComponent(path: String) -> String {
32+
func appendingPathComponent(path: String) -> String {
3333
let nsString = self as NSString
3434
return nsString.appendingPathComponent(path)
3535
}
3636

37-
public func appendingPathExtension(ext: String) -> String? {
37+
func appendingPathExtension(ext: String) -> String? {
3838
let nsString = self as NSString
3939
return nsString.appendingPathExtension(ext)
4040
}

Sources/ScriptToolkit/String+Substrings.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,60 @@
99
import Foundation
1010

1111
public extension String {
12-
public subscript(value: NSRange) -> Substring {
12+
subscript(value: NSRange) -> Substring {
1313
return self[value.lowerBound ..< value.upperBound]
1414
}
1515
}
1616

1717
// MARK: - Subscripts
1818

1919
public extension String {
20-
public subscript(value: CountableClosedRange<Int>) -> Substring {
20+
subscript(value: CountableClosedRange<Int>) -> Substring {
2121
return self[index(at: value.lowerBound) ... index(at: value.upperBound)]
2222
}
2323

24-
public subscript(value: CountableRange<Int>) -> Substring {
24+
subscript(value: CountableRange<Int>) -> Substring {
2525
return self[index(at: value.lowerBound) ..< index(at: value.upperBound)]
2626
}
2727

28-
public subscript(value: PartialRangeUpTo<Int>) -> Substring {
28+
subscript(value: PartialRangeUpTo<Int>) -> Substring {
2929
return self[..<index(at: value.upperBound)]
3030
}
3131

32-
public subscript(value: PartialRangeThrough<Int>) -> Substring {
32+
subscript(value: PartialRangeThrough<Int>) -> Substring {
3333
return self[...index(at: value.upperBound)]
3434
}
3535

36-
public subscript(value: PartialRangeFrom<Int>) -> Substring {
36+
subscript(value: PartialRangeFrom<Int>) -> Substring {
3737
return self[index(at: value.lowerBound)...]
3838
}
3939

40-
public func index(at offset: Int) -> String.Index {
40+
func index(at offset: Int) -> String.Index {
4141
return index(startIndex, offsetBy: offset)
4242
}
4343
}
4444

4545
// MARK: - Safe subscripts
4646

4747
public extension String {
48-
public subscript(safe value: CountableClosedRange<Int>) -> Substring {
48+
subscript(safe value: CountableClosedRange<Int>) -> Substring {
4949
let lowerBound = max(value.lowerBound, 0)
5050
let upperBound = min(value.upperBound, max(count - 1, 0))
5151
return self[index(at: lowerBound) ... index(at: upperBound)]
5252
}
5353

54-
public subscript(safe value: CountableRange<Int>) -> Substring {
54+
subscript(safe value: CountableRange<Int>) -> Substring {
5555
let lowerBound = max(value.lowerBound, 0)
5656
let upperBound = min(value.upperBound, max(count, 0))
5757
return self[index(at: lowerBound) ..< index(at: upperBound)]
5858
}
5959

60-
public subscript(safe value: PartialRangeUpTo<Int>) -> Substring {
60+
subscript(safe value: PartialRangeUpTo<Int>) -> Substring {
6161
let upperBound = min(value.upperBound, max(count, 0))
6262
return self[..<index(at: upperBound)]
6363
}
6464

65-
public subscript(safe value: PartialRangeThrough<Int>) -> Substring {
65+
subscript(safe value: PartialRangeThrough<Int>) -> Substring {
6666
let upperBound: Int
6767
if value.upperBound >= 0 {
6868
upperBound = min(value.upperBound, max(count - 1, 0))
@@ -74,7 +74,7 @@ public extension String {
7474
return self[...index(at: upperBound)]
7575
}
7676

77-
public subscript(safe value: PartialRangeFrom<Int>) -> Substring {
77+
subscript(safe value: PartialRangeFrom<Int>) -> Substring {
7878
let lowerBound = max(value.lowerBound, 0)
7979
return self[index(at: lowerBound)...]
8080
}

0 commit comments

Comments
 (0)