@@ -75,7 +75,7 @@ public override NtStatus CreateFile(string fileName, FileAccess access, FileShar
7575
7676 case FileMode . CreateNew :
7777 {
78- if ( Specifics . Options . IsReadOnly )
78+ if ( specifics . Options . IsReadOnly )
7979 throw FileSystemExceptions . FileSystemReadOnly ;
8080
8181 if ( Directory . Exists ( ciphertextPath ) )
@@ -102,7 +102,7 @@ public override NtStatus CreateFile(string fileName, FileAccess access, FileShar
102102 directoryIdStream . Write ( directoryId ) ;
103103
104104 // Set DirectoryID to known IDs
105- Specifics . DirectoryIdCache . CacheSet ( directoryIdPath , new ( directoryId ) ) ;
105+ specifics . DirectoryIdCache . CacheSet ( directoryIdPath , new ( directoryId ) ) ;
106106 break ;
107107 }
108108 }
@@ -169,7 +169,7 @@ public override NtStatus CreateFile(string fileName, FileAccess access, FileShar
169169
170170 try
171171 {
172- if ( Specifics . Options . IsReadOnly && mode . IsWriteFlag ( ) )
172+ if ( specifics . Options . IsReadOnly && mode . IsWriteFlag ( ) )
173173 throw FileSystemExceptions . FileSystemReadOnly ;
174174
175175 var openAccess = readAccess ? System . IO . FileAccess . Read : System . IO . FileAccess . ReadWrite ;
@@ -234,7 +234,7 @@ public override void Cleanup(string fileName, IDokanFileInfo info)
234234 InvalidateContext ( info ) ;
235235
236236 // Make sure we delete redirected items from DeleteDirectory() and DeleteFile() here.
237- if ( info . DeletePending && ! Specifics . Options . IsReadOnly )
237+ if ( info . DeletePending && ! specifics . Options . IsReadOnly )
238238 {
239239 var ciphertextPath = GetCiphertextPath ( fileName ) ;
240240 if ( ciphertextPath is null )
@@ -245,12 +245,12 @@ public override void Cleanup(string fileName, IDokanFileInfo info)
245245 if ( info . IsDirectory )
246246 {
247247 var directoryIdPath = Path . Combine ( ciphertextPath , FileSystem . Constants . Names . DIRECTORY_ID_FILENAME ) ;
248- Specifics . DirectoryIdCache . CacheRemove ( directoryIdPath ) ;
249- NativeRecycleBinHelpers . DeleteOrRecycle ( ciphertextPath , Specifics , StorableType . Folder ) ;
248+ specifics . DirectoryIdCache . CacheRemove ( directoryIdPath ) ;
249+ NativeRecycleBinHelpers . DeleteOrRecycle ( ciphertextPath , specifics , StorableType . Folder ) ;
250250 }
251251 else
252252 {
253- NativeRecycleBinHelpers . DeleteOrRecycle ( ciphertextPath , Specifics , StorableType . File ) ;
253+ NativeRecycleBinHelpers . DeleteOrRecycle ( ciphertextPath , specifics , StorableType . File ) ;
254254 }
255255 }
256256 catch ( UnauthorizedAccessException )
@@ -283,7 +283,7 @@ public override NtStatus GetFileInformation(string fileName, out FileInformation
283283 LastAccessTime = fsInfo . LastAccessTime ,
284284 LastWriteTime = fsInfo . LastWriteTime ,
285285 Length = fsInfo is FileInfo fileInfo2
286- ? Specifics . Security . ContentCrypt . CalculatePlaintextSize ( Math . Max ( 0L , fileInfo2 . Length - Specifics . Security . HeaderCrypt . HeaderCiphertextSize ) )
286+ ? specifics . Security . ContentCrypt . CalculatePlaintextSize ( Math . Max ( 0L , fileInfo2 . Length - specifics . Security . HeaderCrypt . HeaderCiphertextSize ) )
287287 : 0L
288288 } ;
289289
@@ -322,9 +322,9 @@ public override NtStatus GetDiskFreeSpace(out long freeBytesAvailable, out long
322322 if ( _vaultDriveInfo is null && _vaultDriveInfoTries < Constants . Dokan . MAX_DRIVE_INFO_CALLS_UNTIL_GIVE_UP )
323323 {
324324 _vaultDriveInfoTries ++ ;
325- _vaultDriveInfo ??= DriveInfo . GetDrives ( ) . SingleOrDefault ( di =>
325+ _vaultDriveInfo ??= DriveInfo . GetDrives ( ) . SingleOrDefault ( di =>
326326 di . IsReady &&
327- di . RootDirectory . Name . Equals ( Path . GetPathRoot ( Specifics . ContentFolder . Id ) , StringComparison . OrdinalIgnoreCase ) ) ;
327+ di . RootDirectory . Name . Equals ( Path . GetPathRoot ( specifics . ContentFolder . Id ) , StringComparison . OrdinalIgnoreCase ) ) ;
328328 }
329329
330330 freeBytesAvailable = _vaultDriveInfo ? . TotalFreeSpace ?? 0L ;
@@ -349,21 +349,18 @@ public override NtStatus FindFilesWithPattern(string fileName, string searchPatt
349349 var directory = new DirectoryInfo ( ciphertextPath ) ;
350350 List < FileInformation > ? fileList = null ;
351351
352- var directoryId = AbstractPathHelpers . AllocateDirectoryId ( Specifics . Security , fileName ) ;
353- var itemsEnumerable = Specifics . Security . NameCrypt is null ? directory . EnumerateFileSystemInfos ( searchPattern ) : directory . EnumerateFileSystemInfos ( ) ;
354-
352+ var directoryId = AbstractPathHelpers . AllocateDirectoryId ( specifics . Security , fileName ) ;
353+ var itemsEnumerable = specifics . Security . NameCrypt is null ? directory . EnumerateFileSystemInfos ( searchPattern ) : directory . EnumerateFileSystemInfos ( ) ;
355354 foreach ( var item in itemsEnumerable )
356355 {
357356 if ( PathHelpers . IsCoreName ( item . Name ) )
358357 continue ;
359358
360- var plaintextName = NativePathHelpers . GetPlaintextPath ( item . FullName , Specifics , directoryId ) ;
361- plaintextName = plaintextName is not null ? Path . GetFileName ( plaintextName ) : null ;
362-
359+ var plaintextName = NativePathHelpers . DecryptName ( item . Name , directory . FullName , specifics , directoryId ) ;
363360 if ( string . IsNullOrEmpty ( plaintextName ) )
364361 continue ;
365362
366- if ( Specifics . Security . NameCrypt is not null && ! UnsafeNativeApis . PathMatchSpec ( plaintextName , searchPattern ) )
363+ if ( specifics . Security . NameCrypt is not null && ! UnsafeNativeApis . PathMatchSpec ( plaintextName , searchPattern ) )
367364 continue ;
368365
369366 fileList ??= new ( ) ;
@@ -375,7 +372,7 @@ public override NtStatus FindFilesWithPattern(string fileName, string searchPatt
375372 LastAccessTime = item . LastAccessTime ,
376373 LastWriteTime = item . LastWriteTime ,
377374 Length = item is FileInfo fileInfo
378- ? Specifics . Security . ContentCrypt . CalculatePlaintextSize ( Math . Max ( 0L , fileInfo . Length - Specifics . Security . HeaderCrypt . HeaderCiphertextSize ) )
375+ ? specifics . Security . ContentCrypt . CalculatePlaintextSize ( Math . Max ( 0L , fileInfo . Length - specifics . Security . HeaderCrypt . HeaderCiphertextSize ) )
379376 : 0L
380377 } ) ;
381378 }
@@ -393,7 +390,7 @@ public override NtStatus FindFilesWithPattern(string fileName, string searchPatt
393390 /// <inheritdoc/>
394391 public override NtStatus SetFileAttributes ( string fileName , FileAttributes attributes , IDokanFileInfo info )
395392 {
396- if ( Specifics . Options . IsReadOnly )
393+ if ( specifics . Options . IsReadOnly )
397394 return Trace ( DokanResult . AccessDenied , fileName , info ) ;
398395
399396 try
@@ -489,7 +486,7 @@ public override NtStatus DeleteFile(string fileName, IDokanFileInfo info)
489486 {
490487 // Just check if we can delete the file - the true deletion is done in Cleanup()
491488
492- if ( Specifics . Options . IsReadOnly )
489+ if ( specifics . Options . IsReadOnly )
493490 return Trace ( DokanResult . AccessDenied , fileName , info ) ;
494491
495492 // Get ciphertext path
@@ -513,7 +510,7 @@ public override NtStatus DeleteFile(string fileName, IDokanFileInfo info)
513510 /// <inheritdoc/>
514511 public override NtStatus DeleteDirectory ( string fileName , IDokanFileInfo info )
515512 {
516- if ( Specifics . Options . IsReadOnly )
513+ if ( specifics . Options . IsReadOnly )
517514 return Trace ( DokanResult . AccessDenied , fileName , info ) ;
518515
519516 var canDelete = true ;
@@ -546,7 +543,7 @@ public override NtStatus MoveFile(string oldName, string newName, bool replace,
546543 if ( oldCiphertextPath is null || newCiphertextPath is null )
547544 return Trace ( NtStatus . ObjectPathInvalid , fileNameCombined , info ) ;
548545
549- if ( Specifics . Options . IsReadOnly )
546+ if ( specifics . Options . IsReadOnly )
550547 return Trace ( DokanResult . AccessDenied , fileNameCombined , info ) ;
551548
552549 CloseHandle ( info ) ;
@@ -720,7 +717,7 @@ public override NtStatus GetFileSecurity(string fileName, out FileSystemSecurity
720717 /// <inheritdoc/>
721718 public override NtStatus SetFileSecurity ( string fileName , FileSystemSecurity security , AccessControlSections sections , IDokanFileInfo info )
722719 {
723- if ( Specifics . Options . IsReadOnly )
720+ if ( specifics . Options . IsReadOnly )
724721 return Trace ( DokanResult . AccessDenied , fileName , info ) ;
725722
726723 try
@@ -825,7 +822,7 @@ public override NtStatus FindStreams(string fileName, out IList<FileInformation>
825822 /// <inheritdoc/>
826823 protected override string ? GetCiphertextPath ( string plaintextName )
827824 {
828- return NativePathHelpers . GetCiphertextPath ( plaintextName , Specifics ) ;
825+ return NativePathHelpers . GetCiphertextPath ( plaintextName , specifics ) ;
829826 }
830827 }
831828}
0 commit comments