77// Which is released under the MS-PL license.
88//-----------------------------------------------------------------------
99
10- using System . Threading ;
11- using System . Threading . Tasks ;
12-
1310namespace PCLExt . FileStorage
1411{
1512 /// <summary>
@@ -24,14 +21,12 @@ public class DesktopFileSystem : IFileSystem
2421 static string MacHomeDirectory => ( ( Foundation . NSString ) ObjCRuntime . Runtime . GetNSObject ( NSHomeDirectory ( ) ) ) . ToString ( ) ;
2522#endif
2623
27- /// <summary>
28- /// A folder representing storage which is where the app is running.
29- /// </summary>
30- public IFolder BaseStorage
24+ /// <inheritdoc />
25+ public IFolder BaseStorage
3126 {
3227 get
3328 {
34- #if ANDROID || __IOS__ || OSX
29+ #if ANDROID || __IOS__
3530 var storage = "" ;
3631 return null ;
3732#elif DESKTOP || MAC
@@ -41,17 +36,15 @@ public IFolder BaseStorage
4136 }
4237 }
4338
44- /// <summary>
45- /// A folder representing storage which is local to the current device.
46- /// </summary>
47- public IFolder LocalStorage
39+ /// <inheritdoc />
40+ public IFolder LocalStorage
4841 {
4942 get
5043 {
5144#if ANDROID
5245 var storage = Android . App . Application . Context . GetExternalFilesDir ( null ) ? . ParentFile ? . AbsolutePath ;
5346 if ( string . IsNullOrEmpty ( storage ) )
54- return null ;
47+ return null ;
5548#elif __IOS__
5649 var documents = System . Environment . GetFolderPath ( System . Environment . SpecialFolder . MyDocuments ) ;
5750 var storage = System . IO . Path . Combine ( documents , ".." , "Library" ) ;
@@ -73,17 +66,15 @@ public IFolder LocalStorage
7366 }
7467 }
7568
76- /// <summary>
77- /// A folder representing storage which may be synced with other devices for the same user.
78- /// </summary>
79- public IFolder RoamingStorage
69+ /// <inheritdoc />
70+ public IFolder RoamingStorage
8071 {
8172 get
8273 {
8374#if ANDROID
8475 var storage = System . Environment . GetFolderPath ( System . Environment . SpecialFolder . MyDocuments ) ;
8576
86- #elif __IOS__ || OSX || MAC
77+ #elif __IOS__ || MAC
8778 var storage = "" ;
8879 return null ;
8980#elif DESKTOP
@@ -93,68 +84,20 @@ public IFolder RoamingStorage
9384 }
9485 }
9586
96- /// <summary>
97- /// Gets a file, given its path. Returns null if the file does not exist.
98- /// </summary>
99- /// <param name="path">The path to a file, as returned from the <see cref="IFile.Path"/> property.</param>
100- /// <returns>A file for the given path, or null if it does not exist.</returns>
101- public IFile GetFileFromPath ( string path )
102- {
103- Requires . NotNullOrEmpty ( path , "path" ) ;
104-
105- if ( System . IO . File . Exists ( path ) )
106- return new FileSystemFile ( path ) ;
107-
108- return null ;
109- }
110-
111- /// <summary>
112- /// Gets a file, given its path. Returns null if the file does not exist.
113- /// </summary>
114- /// <param name="path">The path to a file, as returned from the <see cref="IFile.Path"/> property.</param>
115- /// <param name="cancellationToken">The cancellation token.</param>
116- /// <returns>A file for the given path, or null if it does not exist.</returns>
117- public async Task < IFile > GetFileFromPathAsync ( string path , CancellationToken cancellationToken )
118- {
119- Requires . NotNullOrEmpty ( path , "path" ) ;
120-
121- await AwaitExtensions . SwitchOffMainThreadAsync ( cancellationToken ) ;
122- if ( System . IO . File . Exists ( path ) )
123- return new FileSystemFile ( path ) ;
124-
125- return null ;
126- }
127-
128- /// <summary>
129- /// Gets a folder, given its path. Returns null if the folder does not exist.
130- /// </summary>
131- /// <param name="path">The path to a folder, as returned from the <see cref="IFolder.Path"/> property.</param>
132- /// <returns>A folder for the specified path, or null if it does not exist.</returns>
133- public IFolder GetFolderFromPath ( string path )
87+ /// <inheritdoc />
88+ public IFolder SpecialStorage
13489 {
135- Requires . NotNullOrEmpty ( path , "path" ) ;
90+ get
91+ {
92+ #if DESKTOP || MAC
93+ return BaseStorage ;
13694
137- if ( System . IO . Directory . Exists ( path ) )
138- return new FileSystemFolder ( path , true ) ;
139-
140- return null ;
141- }
142-
143- /// <summary>
144- /// Gets a folder, given its path. Returns null if the folder does not exist.
145- /// </summary>
146- /// <param name="path">The path to a folder, as returned from the <see cref="IFolder.Path"/> property.</param>
147- /// <param name="cancellationToken">The cancellation token.</param>
148- /// <returns>A folder for the specified path, or null if it does not exist.</returns>
149- public async Task < IFolder > GetFolderFromPathAsync ( string path , CancellationToken cancellationToken )
150- {
151- Requires . NotNullOrEmpty ( path , "path" ) ;
152-
153- await AwaitExtensions . SwitchOffMainThreadAsync ( cancellationToken ) ;
154- if ( System . IO . Directory . Exists ( path ) )
155- return new FileSystemFolder ( path , true ) ;
95+ #elif ANDROID || __IOS__
96+ return LocalStorage ;
97+ #endif
15698
157- return null ;
99+ return null ;
100+ }
158101 }
159102 }
160103}
0 commit comments