Skip to content

Commit 5facd05

Browse files
committed
[path_provider_foundation] Run swift-format on Swift files
1 parent 76a6fd2 commit 5facd05

File tree

2 files changed

+54
-52
lines changed

2 files changed

+54
-52
lines changed

packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,62 +5,63 @@
55
import Foundation
66

77
#if os(iOS)
8-
import Flutter
8+
import Flutter
99
#elseif os(macOS)
10-
import FlutterMacOS
10+
import FlutterMacOS
1111
#endif
1212

1313
public class PathProviderPlugin: NSObject, FlutterPlugin, PathProviderApi {
1414
public static func register(with registrar: FlutterPluginRegistrar) {
1515
let instance = PathProviderPlugin()
1616
// Workaround for https://github.com/flutter/flutter/issues/118103.
17-
#if os(iOS)
18-
let messenger = registrar.messenger()
19-
#else
20-
let messenger = registrar.messenger
21-
#endif
17+
#if os(iOS)
18+
let messenger = registrar.messenger()
19+
#else
20+
let messenger = registrar.messenger
21+
#endif
2222
PathProviderApiSetup.setUp(binaryMessenger: messenger, api: instance)
2323
}
2424

2525
func getDirectoryPath(type: DirectoryType) -> String? {
2626
var path = getDirectory(ofType: fileManagerDirectoryForType(type))
27-
#if os(macOS)
28-
// In a non-sandboxed app, these are shared directories where applications are
29-
// expected to use its bundle ID as a subdirectory. (For non-sandboxed apps,
30-
// adding the extra path is harmless).
31-
// This is not done for iOS, for compatibility with older versions of the
32-
// plugin.
33-
if type == .applicationSupport || type == .applicationCache {
34-
if let basePath = path {
35-
let basePathURL = URL.init(fileURLWithPath: basePath)
36-
path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path
27+
#if os(macOS)
28+
// In a non-sandboxed app, these are shared directories where applications are
29+
// expected to use its bundle ID as a subdirectory. (For non-sandboxed apps,
30+
// adding the extra path is harmless).
31+
// This is not done for iOS, for compatibility with older versions of the
32+
// plugin.
33+
if type == .applicationSupport || type == .applicationCache {
34+
if let basePath = path {
35+
let basePathURL = URL.init(fileURLWithPath: basePath)
36+
path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path
37+
}
3738
}
38-
}
39-
#endif
39+
#endif
4040
return path
4141
}
4242

4343
// Returns the path for the container of the specified app group.
4444
func getContainerPath(appGroupIdentifier: String) -> String? {
45-
return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.path
45+
return FileManager.default.containerURL(
46+
forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.path
4647
}
4748
}
4849

4950
/// Returns the FileManager constant corresponding to the given type.
5051
private func fileManagerDirectoryForType(_ type: DirectoryType) -> FileManager.SearchPathDirectory {
5152
switch type {
52-
case .applicationCache:
53-
return FileManager.SearchPathDirectory.cachesDirectory
54-
case .applicationDocuments:
55-
return FileManager.SearchPathDirectory.documentDirectory
56-
case .applicationSupport:
57-
return FileManager.SearchPathDirectory.applicationSupportDirectory
58-
case .downloads:
59-
return FileManager.SearchPathDirectory.downloadsDirectory
60-
case .library:
61-
return FileManager.SearchPathDirectory.libraryDirectory
62-
case .temp:
63-
return FileManager.SearchPathDirectory.cachesDirectory
53+
case .applicationCache:
54+
return FileManager.SearchPathDirectory.cachesDirectory
55+
case .applicationDocuments:
56+
return FileManager.SearchPathDirectory.documentDirectory
57+
case .applicationSupport:
58+
return FileManager.SearchPathDirectory.applicationSupportDirectory
59+
case .downloads:
60+
return FileManager.SearchPathDirectory.downloadsDirectory
61+
case .library:
62+
return FileManager.SearchPathDirectory.libraryDirectory
63+
case .temp:
64+
return FileManager.SearchPathDirectory.cachesDirectory
6465
}
6566
}
6667

packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
// found in the LICENSE file.
44

55
import XCTest
6+
67
@testable import path_provider_foundation
78

89
#if os(iOS)
9-
import Flutter
10+
import Flutter
1011
#elseif os(macOS)
11-
import FlutterMacOS
12+
import FlutterMacOS
1213
#endif
1314

1415
class RunnerTests: XCTestCase {
@@ -39,28 +40,28 @@ class RunnerTests: XCTestCase {
3940
func testGetApplicationSupportDirectory() throws {
4041
let plugin = PathProviderPlugin()
4142
let path = plugin.getDirectoryPath(type: .applicationSupport)
42-
#if os(iOS)
43-
// On iOS, the application support directory path should be just the system application
44-
// support path.
45-
XCTAssertEqual(
46-
path,
47-
NSSearchPathForDirectoriesInDomains(
48-
FileManager.SearchPathDirectory.applicationSupportDirectory,
49-
FileManager.SearchPathDomainMask.userDomainMask,
50-
true
51-
).first)
52-
#else
53-
// On macOS, the application support directory path should be the system application
54-
// support path with an added subdirectory based on the app name.
55-
XCTAssert(
56-
path!.hasPrefix(
43+
#if os(iOS)
44+
// On iOS, the application support directory path should be just the system application
45+
// support path.
46+
XCTAssertEqual(
47+
path,
5748
NSSearchPathForDirectoriesInDomains(
5849
FileManager.SearchPathDirectory.applicationSupportDirectory,
5950
FileManager.SearchPathDomainMask.userDomainMask,
6051
true
61-
).first!))
62-
XCTAssert(path!.hasSuffix("Example"))
63-
#endif
52+
).first)
53+
#else
54+
// On macOS, the application support directory path should be the system application
55+
// support path with an added subdirectory based on the app name.
56+
XCTAssert(
57+
path!.hasPrefix(
58+
NSSearchPathForDirectoriesInDomains(
59+
FileManager.SearchPathDirectory.applicationSupportDirectory,
60+
FileManager.SearchPathDomainMask.userDomainMask,
61+
true
62+
).first!))
63+
XCTAssert(path!.hasSuffix("Example"))
64+
#endif
6465
}
6566

6667
func testGetLibraryDirectory() throws {

0 commit comments

Comments
 (0)