[path_provider_foundation] Run swift-format on Swift files (#5935)
Run `swift-format` linter/formatter on Swift files.
Part of turning on swift-format CI formatting https://github.com/flutter/packages/pull/5928
diff --git a/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift b/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift
index 5530b8b..16f2edb 100644
--- a/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift
+++ b/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift
@@ -5,62 +5,63 @@
import Foundation
#if os(iOS)
-import Flutter
+ import Flutter
#elseif os(macOS)
-import FlutterMacOS
+ import FlutterMacOS
#endif
public class PathProviderPlugin: NSObject, FlutterPlugin, PathProviderApi {
public static func register(with registrar: FlutterPluginRegistrar) {
let instance = PathProviderPlugin()
// Workaround for https://github.com/flutter/flutter/issues/118103.
-#if os(iOS)
- let messenger = registrar.messenger()
-#else
- let messenger = registrar.messenger
-#endif
+ #if os(iOS)
+ let messenger = registrar.messenger()
+ #else
+ let messenger = registrar.messenger
+ #endif
PathProviderApiSetup.setUp(binaryMessenger: messenger, api: instance)
}
func getDirectoryPath(type: DirectoryType) -> String? {
var path = getDirectory(ofType: fileManagerDirectoryForType(type))
- #if os(macOS)
- // In a non-sandboxed app, these are shared directories where applications are
- // expected to use its bundle ID as a subdirectory. (For non-sandboxed apps,
- // adding the extra path is harmless).
- // This is not done for iOS, for compatibility with older versions of the
- // plugin.
- if type == .applicationSupport || type == .applicationCache {
- if let basePath = path {
- let basePathURL = URL.init(fileURLWithPath: basePath)
- path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path
+ #if os(macOS)
+ // In a non-sandboxed app, these are shared directories where applications are
+ // expected to use its bundle ID as a subdirectory. (For non-sandboxed apps,
+ // adding the extra path is harmless).
+ // This is not done for iOS, for compatibility with older versions of the
+ // plugin.
+ if type == .applicationSupport || type == .applicationCache {
+ if let basePath = path {
+ let basePathURL = URL.init(fileURLWithPath: basePath)
+ path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path
+ }
}
- }
- #endif
+ #endif
return path
}
// Returns the path for the container of the specified app group.
func getContainerPath(appGroupIdentifier: String) -> String? {
- return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.path
+ return FileManager.default.containerURL(
+ forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.path
}
}
/// Returns the FileManager constant corresponding to the given type.
private func fileManagerDirectoryForType(_ type: DirectoryType) -> FileManager.SearchPathDirectory {
switch type {
- case .applicationCache:
- return FileManager.SearchPathDirectory.cachesDirectory
- case .applicationDocuments:
- return FileManager.SearchPathDirectory.documentDirectory
- case .applicationSupport:
- return FileManager.SearchPathDirectory.applicationSupportDirectory
- case .downloads:
- return FileManager.SearchPathDirectory.downloadsDirectory
- case .library:
- return FileManager.SearchPathDirectory.libraryDirectory
- case .temp:
- return FileManager.SearchPathDirectory.cachesDirectory
+ case .applicationCache:
+ return FileManager.SearchPathDirectory.cachesDirectory
+ case .applicationDocuments:
+ return FileManager.SearchPathDirectory.documentDirectory
+ case .applicationSupport:
+ return FileManager.SearchPathDirectory.applicationSupportDirectory
+ case .downloads:
+ return FileManager.SearchPathDirectory.downloadsDirectory
+ case .library:
+ return FileManager.SearchPathDirectory.libraryDirectory
+ case .temp:
+ return FileManager.SearchPathDirectory.cachesDirectory
}
}
diff --git a/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift b/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift
index 99a56f2..67ee981 100644
--- a/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift
+++ b/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift
@@ -3,12 +3,13 @@
// found in the LICENSE file.
import XCTest
+
@testable import path_provider_foundation
#if os(iOS)
-import Flutter
+ import Flutter
#elseif os(macOS)
-import FlutterMacOS
+ import FlutterMacOS
#endif
class RunnerTests: XCTestCase {
@@ -39,28 +40,28 @@
func testGetApplicationSupportDirectory() throws {
let plugin = PathProviderPlugin()
let path = plugin.getDirectoryPath(type: .applicationSupport)
-#if os(iOS)
- // On iOS, the application support directory path should be just the system application
- // support path.
- XCTAssertEqual(
- path,
- NSSearchPathForDirectoriesInDomains(
- FileManager.SearchPathDirectory.applicationSupportDirectory,
- FileManager.SearchPathDomainMask.userDomainMask,
- true
- ).first)
-#else
- // On macOS, the application support directory path should be the system application
- // support path with an added subdirectory based on the app name.
- XCTAssert(
- path!.hasPrefix(
+ #if os(iOS)
+ // On iOS, the application support directory path should be just the system application
+ // support path.
+ XCTAssertEqual(
+ path,
NSSearchPathForDirectoriesInDomains(
FileManager.SearchPathDirectory.applicationSupportDirectory,
FileManager.SearchPathDomainMask.userDomainMask,
true
- ).first!))
- XCTAssert(path!.hasSuffix("Example"))
-#endif
+ ).first)
+ #else
+ // On macOS, the application support directory path should be the system application
+ // support path with an added subdirectory based on the app name.
+ XCTAssert(
+ path!.hasPrefix(
+ NSSearchPathForDirectoriesInDomains(
+ FileManager.SearchPathDirectory.applicationSupportDirectory,
+ FileManager.SearchPathDomainMask.userDomainMask,
+ true
+ ).first!))
+ XCTAssert(path!.hasSuffix("Example"))
+ #endif
}
func testGetLibraryDirectory() throws {