File tree 5 files changed +40
-40
lines changed
Modules/Sources/WordPressShared/FileManager
Classes/Utility/Blogging Prompts
5 files changed +40
-40
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ import Foundation
2
+
3
+ extension FileManager : LocalFileStore {
4
+ public func containerURL( forAppGroup appGroup: String ) -> URL ? {
5
+ return containerURL ( forSecurityApplicationGroupIdentifier: appGroup)
6
+ }
7
+
8
+ public func fileExists( at url: URL ) -> Bool {
9
+ return fileExists ( atPath: url. path)
10
+ }
11
+
12
+ @discardableResult
13
+ public func save( contents: Data , at url: URL ) -> Bool {
14
+ return createFile ( atPath: url. path, contents: contents)
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ import Foundation
2
+
3
+ public protocol LocalFileStore {
4
+ func data( from url: URL ) throws -> Data
5
+
6
+ func fileExists( at url: URL ) -> Bool
7
+
8
+ @discardableResult
9
+ func save( contents: Data , at url: URL ) -> Bool
10
+
11
+ func containerURL( forAppGroup appGroup: String ) -> URL ?
12
+
13
+ func removeItem( at url: URL ) throws
14
+
15
+ func copyItem( at srcURL: URL , to dstURL: URL ) throws
16
+ }
17
+
18
+ public extension LocalFileStore {
19
+ func data( from url: URL ) throws -> Data {
20
+ return try Data ( contentsOf: url)
21
+ }
22
+ }
Original file line number Diff line number Diff line change 1
1
import Foundation
2
2
import UserNotifications
3
+ import WordPressShared
3
4
4
5
/// Encapsulates the local notification scheduling logic for Blogging Prompts.
5
6
///
@@ -459,43 +460,3 @@ struct DefaultCurrentDateProvider: CurrentDateProvider {
459
460
}
460
461
}
461
462
462
- // MARK: - Local Store
463
-
464
- /// A wrapper protocol intended for `FileManager`.
465
- /// Created to simplify unit testing.
466
- ///
467
- protocol LocalFileStore {
468
- func data( from url: URL ) throws -> Data
469
-
470
- func fileExists( at url: URL ) -> Bool
471
-
472
- @discardableResult
473
- func save( contents: Data , at url: URL ) -> Bool
474
-
475
- func containerURL( forAppGroup appGroup: String ) -> URL ?
476
-
477
- func removeItem( at url: URL ) throws
478
-
479
- func copyItem( at srcURL: URL , to dstURL: URL ) throws
480
- }
481
-
482
- extension LocalFileStore {
483
- func data( from url: URL ) throws -> Data {
484
- return try Data ( contentsOf: url)
485
- }
486
- }
487
-
488
- extension FileManager : LocalFileStore {
489
- func containerURL( forAppGroup appGroup: String ) -> URL ? {
490
- return containerURL ( forSecurityApplicationGroupIdentifier: appGroup)
491
- }
492
-
493
- func fileExists( at url: URL ) -> Bool {
494
- return fileExists ( atPath: url. path)
495
- }
496
-
497
- @discardableResult
498
- func save( contents: Data , at url: URL ) -> Bool {
499
- return createFile ( atPath: url. path, contents: contents)
500
- }
501
- }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import XCTest
2
2
import OHHTTPStubs
3
3
import OHHTTPStubsSwift
4
4
import CoreData
5
+ import WordPressShared
5
6
6
7
@testable import WordPress
7
8
You can’t perform that action at this time.
0 commit comments