зеркало из https://github.com/mozilla/glean.git
[Swift] Remove unused utility functions
This commit is contained in:
Родитель
63a52d8a83
Коммит
c7bb0298bf
|
@ -69,35 +69,6 @@ extension Date {
|
|||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
/// Create a string from a Rust-allocated char pointer and deallocate the char pointer.
|
||||
public init(freeingGleanString rustString: UnsafeMutablePointer<CChar>) {
|
||||
defer { glean_str_free(rustString) }
|
||||
self.init(cString: rustString)
|
||||
}
|
||||
|
||||
/// Checks to see if a string matches a regex
|
||||
///
|
||||
/// - returns: true if the string matches the regex
|
||||
func matches(_ regex: String) -> Bool {
|
||||
return self.range(of: regex, options: .regularExpression, range: nil, locale: nil) != nil
|
||||
}
|
||||
|
||||
/// Conveniently convert a string path to a file URL
|
||||
///
|
||||
/// - returns: File `URL` represeting the path contained in the string
|
||||
var fileURL: URL {
|
||||
return URL(fileURLWithPath: self)
|
||||
}
|
||||
|
||||
/// Gets the last path components, such as the file name from a string path
|
||||
///
|
||||
/// - returns: `String` representing the last path component
|
||||
var lastPathComponent: String {
|
||||
return fileURL.lastPathComponent
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to retrive the application's Application Support directory for persistent file storage
|
||||
///
|
||||
/// - returns: `URL` of the Application Support directory
|
||||
|
@ -107,31 +78,6 @@ func getGleanDirectory() -> URL {
|
|||
return documentsDirectory.appendingPathComponent("glean_data")
|
||||
}
|
||||
|
||||
// swiftlint:enable function_parameter_count
|
||||
|
||||
/// Create a temporary array of C-compatible (null-terminated) strings to pass over FFI.
|
||||
///
|
||||
/// The strings are deallocated after the closure returns.
|
||||
///
|
||||
/// - parameters:
|
||||
/// * args: The array of strings to use.
|
||||
// If `nil` no output array will be allocated and `nil` will be passed to `body`.
|
||||
/// * body: The closure that gets an array of C-compatible strings
|
||||
func withArrayOfCStrings<R>(
|
||||
_ args: [String]?,
|
||||
_ body: ([UnsafePointer<CChar>?]?) -> R
|
||||
) -> R {
|
||||
if let args = args {
|
||||
let cStrings = args.map { UnsafePointer(strdup($0)) }
|
||||
defer {
|
||||
cStrings.forEach { free(UnsafeMutableRawPointer(mutating: $0)) }
|
||||
}
|
||||
return body(cStrings)
|
||||
} else {
|
||||
return body(nil)
|
||||
}
|
||||
}
|
||||
|
||||
/// This struct creates a Boolean with atomic or synchronized access.
|
||||
///
|
||||
/// This makes use of synchronization tools from Grand Central Dispatch (GCD)
|
||||
|
|
Загрузка…
Ссылка в новой задаче