@@ -33,15 +33,15 @@ public override void Connect()
3333 {
3434 }
3535
36- public override async Task < IFile > GetFileAsync ( string path , CancellationToken cancellationToken = default )
36+ public override async Task < IFile > GetFileAsync ( string virtualPath , CancellationToken cancellationToken = default )
3737 {
38- path = PrependRootPath ( path ) ;
38+ var path = GetPath ( virtualPath ) ;
3939
4040 try
4141 {
4242 using var response = await client . GetObjectAsync ( bucketName , path , cancellationToken ) ;
4343
44- return ModelFactory . CreateFile ( response ) ;
44+ return ModelFactory . CreateFile ( response , virtualPath ) ;
4545 }
4646 catch ( AmazonS3Exception exception )
4747 {
@@ -58,9 +58,9 @@ public override async Task<IFile> GetFileAsync(string path, CancellationToken ca
5858 }
5959 }
6060
61- public override async Task < IDirectory > GetDirectoryAsync ( string path , CancellationToken cancellationToken = default )
61+ public override async Task < IDirectory > GetDirectoryAsync ( string virtualPath , CancellationToken cancellationToken = default )
6262 {
63- path = PrependRootPath ( path ) ;
63+ var path = GetPath ( virtualPath ) ;
6464
6565 if ( ! path . EndsWith ( "/" ) )
6666 {
@@ -89,7 +89,7 @@ public override async Task<IDirectory> GetDirectoryAsync(string path, Cancellati
8989 {
9090 if ( item . Key == path )
9191 {
92- return ModelFactory . CreateDirectory ( item ) ;
92+ return ModelFactory . CreateDirectory ( item , virtualPath ) ;
9393 }
9494 }
9595
@@ -101,10 +101,10 @@ public override async Task<IDirectory> GetDirectoryAsync(string path, Cancellati
101101 }
102102 }
103103
104- public override async Task < IEnumerable < IFile > > GetFilesAsync ( string path = "" , CancellationToken cancellationToken = default )
104+ public override async Task < IEnumerable < IFile > > GetFilesAsync ( string virtualPath = "" , CancellationToken cancellationToken = default )
105105 {
106- await GetDirectoryAsync ( path , cancellationToken ) ;
107- path = PrependRootPath ( path ) ;
106+ await GetDirectoryAsync ( virtualPath , cancellationToken ) ;
107+ var path = GetPath ( virtualPath ) ;
108108
109109 try
110110 {
@@ -119,7 +119,7 @@ public override async Task<IEnumerable<IFile>> GetFilesAsync(string path = "", C
119119
120120 if ( ! item . Key . EndsWith ( "/" ) && ! itemName . Contains ( '/' ) )
121121 {
122- files . Add ( ModelFactory . CreateFile ( item ) ) ;
122+ files . Add ( ModelFactory . CreateFile ( item , GetVirtualPath ( item . Key ) ) ) ;
123123 }
124124 }
125125
@@ -131,13 +131,10 @@ public override async Task<IEnumerable<IFile>> GetFilesAsync(string path = "", C
131131 }
132132 }
133133
134- public override async Task < IEnumerable < IDirectory > > GetDirectoriesAsync (
135- string path = "" ,
136- CancellationToken cancellationToken = default
137- )
134+ public override async Task < IEnumerable < IDirectory > > GetDirectoriesAsync ( string virtualPath = "" , CancellationToken cancellationToken = default )
138135 {
139- await GetDirectoryAsync ( path , cancellationToken ) ;
140- path = PrependRootPath ( path ) ;
136+ await GetDirectoryAsync ( virtualPath , cancellationToken ) ;
137+ var path = GetPath ( virtualPath ) ;
141138
142139 try
143140 {
@@ -152,7 +149,7 @@ public override async Task<IEnumerable<IDirectory>> GetDirectoriesAsync(
152149
153150 if ( item . Key . EndsWith ( "/" ) && itemName . Count ( c => c . Equals ( '/' ) ) == 1 )
154151 {
155- directories . Add ( ModelFactory . CreateDirectory ( item ) ) ;
152+ directories . Add ( ModelFactory . CreateDirectory ( item , GetVirtualPath ( item . Key ) ) ) ;
156153 }
157154 }
158155
@@ -164,14 +161,14 @@ public override async Task<IEnumerable<IDirectory>> GetDirectoriesAsync(
164161 }
165162 }
166163
167- public override async Task CreateDirectoryAsync ( string path , CancellationToken cancellationToken = default )
164+ public override async Task CreateDirectoryAsync ( string virtualPath , CancellationToken cancellationToken = default )
168165 {
169- if ( await DirectoryExistsAsync ( path , cancellationToken ) )
166+ if ( await DirectoryExistsAsync ( virtualPath , cancellationToken ) )
170167 {
171- throw new DirectoryExistsException ( PrependRootPath ( path ) , Prefix ) ;
168+ throw new DirectoryExistsException ( GetPath ( virtualPath ) , Prefix ) ;
172169 }
173170
174- path = PrependRootPath ( path ) ;
171+ var path = GetPath ( virtualPath ) ;
175172 path = path . EndsWith ( "/" ) ? path : path + "/" ;
176173
177174 try
@@ -185,11 +182,11 @@ public override async Task CreateDirectoryAsync(string path, CancellationToken c
185182 }
186183 }
187184
188- public override async Task DeleteDirectoryAsync ( string path , CancellationToken cancellationToken = default )
185+ public override async Task DeleteDirectoryAsync ( string virtualPath , CancellationToken cancellationToken = default )
189186 {
190- await GetDirectoryAsync ( path , cancellationToken ) ;
187+ await GetDirectoryAsync ( virtualPath , cancellationToken ) ;
191188
192- path = PrependRootPath ( path ) ;
189+ var path = GetPath ( virtualPath ) ;
193190 path = path . EndsWith ( "/" ) ? path : path + "/" ;
194191
195192 try
@@ -212,10 +209,10 @@ public override async Task DeleteDirectoryAsync(string path, CancellationToken c
212209 }
213210 }
214211
215- public override async Task DeleteFileAsync ( string path , CancellationToken cancellationToken = default )
212+ public override async Task DeleteFileAsync ( string virtualPath , CancellationToken cancellationToken = default )
216213 {
217- await GetFileAsync ( path , cancellationToken ) ;
218- path = PrependRootPath ( path ) ;
214+ await GetFileAsync ( virtualPath , cancellationToken ) ;
215+ var path = GetPath ( virtualPath ) ;
219216
220217 try
221218 {
@@ -227,10 +224,10 @@ public override async Task DeleteFileAsync(string path, CancellationToken cancel
227224 }
228225 }
229226
230- public override async Task < byte [ ] > ReadFileAsync ( string path , CancellationToken cancellationToken = default )
227+ public override async Task < byte [ ] > ReadFileAsync ( string virtualPath , CancellationToken cancellationToken = default )
231228 {
232- await GetFileAsync ( path , cancellationToken ) ;
233- path = PrependRootPath ( path ) ;
229+ await GetFileAsync ( virtualPath , cancellationToken ) ;
230+ var path = GetPath ( virtualPath ) ;
234231
235232 try
236233 {
@@ -246,10 +243,10 @@ public override async Task<byte[]> ReadFileAsync(string path, CancellationToken
246243 }
247244 }
248245
249- public override async Task < string > ReadTextFileAsync ( string path , CancellationToken cancellationToken = default )
246+ public override async Task < string > ReadTextFileAsync ( string virtualPath , CancellationToken cancellationToken = default )
250247 {
251- await GetFileAsync ( path , cancellationToken ) ;
252- path = PrependRootPath ( path ) ;
248+ await GetFileAsync ( virtualPath , cancellationToken ) ;
249+ var path = GetPath ( virtualPath ) ;
253250
254251 try
255252 {
@@ -268,19 +265,14 @@ public override async Task<string> ReadTextFileAsync(string path, CancellationTo
268265 }
269266 }
270267
271- public override async Task WriteFileAsync (
272- string path ,
273- byte [ ] contents ,
274- bool overwrite = false ,
275- CancellationToken cancellationToken = default
276- )
268+ public override async Task WriteFileAsync ( string virtualPath , byte [ ] contents , bool overwrite = false , CancellationToken cancellationToken = default )
277269 {
278- if ( ! overwrite && await FileExistsAsync ( path , cancellationToken ) )
270+ if ( ! overwrite && await FileExistsAsync ( virtualPath , cancellationToken ) )
279271 {
280- throw new FileExistsException ( PrependRootPath ( path ) , Prefix ) ;
272+ throw new FileExistsException ( GetPath ( virtualPath ) , Prefix ) ;
281273 }
282274
283- path = PrependRootPath ( path ) ;
275+ var path = GetPath ( virtualPath ) ;
284276
285277 try
286278 {
@@ -300,14 +292,14 @@ public override async Task WriteFileAsync(
300292 }
301293 }
302294
303- public override async Task AppendFileAsync ( string path , byte [ ] contents , CancellationToken cancellationToken = default )
295+ public override async Task AppendFileAsync ( string virtualPath , byte [ ] contents , CancellationToken cancellationToken = default )
304296 {
305- await GetFileAsync ( path , cancellationToken ) ;
306- var existingContents = await ReadFileAsync ( path , cancellationToken ) ;
297+ await GetFileAsync ( virtualPath , cancellationToken ) ;
298+ var existingContents = await ReadFileAsync ( virtualPath , cancellationToken ) ;
307299 contents = existingContents . Concat ( contents ) . ToArray ( ) ;
308- await DeleteFileAsync ( path , cancellationToken ) ;
300+ await DeleteFileAsync ( virtualPath , cancellationToken ) ;
309301
310- path = PrependRootPath ( path ) ;
302+ var path = GetPath ( virtualPath ) ;
311303
312304 try
313305 {
0 commit comments