-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
102 additions
and
49 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,18 @@ | ||
// | ||
// Created by Florian Kostenzer on 27.04.22. | ||
// | ||
|
||
import Foundation | ||
import ShellOut | ||
|
||
@discardableResult | ||
public func escapedShellOut( | ||
to command: String, | ||
arguments: [String] = [], | ||
at path: String = ".", | ||
process: Process = .init(), | ||
outputHandle: FileHandle? = nil, | ||
errorHandle: FileHandle? = nil | ||
) throws -> String { | ||
return try shellOut(to: command, arguments: arguments.bashEscaped, at: path, process: process, outputHandle: outputHandle, errorHandle: errorHandle) | ||
} |
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 was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
Sources/SwiftTileserverCache/Misc/String+BashEscaped.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,28 @@ | ||
// | ||
// String+BashEncode.swift | ||
// SwiftTileserverCache | ||
// | ||
// Created by Florian Kostenzer on 17.05.20. | ||
// | ||
|
||
import Foundation | ||
|
||
internal extension String { | ||
var bashEscaped: String { | ||
let safeChars = [ | ||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", | ||
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", | ||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", | ||
"/", "-", "+", "_", ",", ".", ":", "=" | ||
] | ||
|
||
return self.trimmingCharacters(in: .nonBaseCharacters).map { char in | ||
let string = String(char) | ||
if safeChars.contains(string) { | ||
return string | ||
} else { | ||
return "\\" + string | ||
} | ||
}.joined() | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Sources/SwiftTileserverCache/Misc/StringArray+BashEscaped.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,14 @@ | ||
// | ||
// String+BashEncode.swift | ||
// SwiftTileserverCache | ||
// | ||
// Created by Florian Kostenzer on 17.05.20. | ||
// | ||
|
||
import Foundation | ||
|
||
internal extension Array where Element == String { | ||
var bashEscaped: [String] { | ||
return self.map({$0.bashEscaped}) | ||
} | ||
} |
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,12 @@ | ||
// | ||
// CombineDirection.swift | ||
// SwiftTileserverCache | ||
// | ||
// Created by Florian Kostenzer on 04.03.20. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum ImageFormat: String, Codable, Hashable { | ||
case png, jpg | ||
} |
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