44using Files . App . Services . SizeProvider ;
55using Files . Shared . Helpers ;
66using System . IO ;
7+ using Vanara . PInvoke ;
78using Windows . Storage ;
8- using static Files . App . Helpers . Win32Helper ;
9+ using static Files . App . Helpers . NativeFindStorageItemHelper ;
910using FileAttributes = System . IO . FileAttributes ;
1011
1112namespace Files . App . Utils . Storage
@@ -17,10 +18,11 @@ public static class Win32StorageEnumerator
1718
1819 private static readonly string folderTypeTextLocalized = "Folder" . GetLocalizedResource ( ) ;
1920
21+
2022 public static async Task < List < ListedItem > > ListEntries (
2123 string path ,
2224 IntPtr hFile ,
23- Win32PInvoke . WIN32_FIND_DATA findData ,
25+ NativeFindStorageItemHelper . WIN32_FIND_DATA findData ,
2426 CancellationToken cancellationToken ,
2527 int countLimit ,
2628 Func < List < ListedItem > , Task > intermediateAction
@@ -97,16 +99,16 @@ Func<List<ListedItem>, Task> intermediateAction
9799 // clear the temporary list every time we do an intermediate action
98100 tempList . Clear ( ) ;
99101 }
100- } while ( Win32PInvoke . FindNextFile ( hFile , out findData ) ) ;
102+ } while ( FindNextFile ( hFile , out findData ) ) ;
101103
102- Win32PInvoke . FindClose ( hFile ) ;
104+ FindClose ( hFile ) ;
103105
104106 return tempList ;
105107 }
106108
107109 private static IEnumerable < ListedItem > EnumAdsForPath ( string itemPath , ListedItem main )
108110 {
109- foreach ( var ads in Win32Helper . GetAlternateStreams ( itemPath ) )
111+ foreach ( var ads in NativeFileOperationsHelper . GetAlternateStreams ( itemPath ) )
110112 yield return GetAlternateStream ( ads , main ) ;
111113 }
112114
@@ -143,7 +145,7 @@ public static ListedItem GetAlternateStream((string Name, long Size) ads, Listed
143145 }
144146
145147 public static async Task < ListedItem > GetFolder (
146- Win32PInvoke . WIN32_FIND_DATA findData ,
148+ NativeFindStorageItemHelper . WIN32_FIND_DATA findData ,
147149 string pathRoot ,
148150 bool isGitRepo ,
149151 CancellationToken cancellationToken
@@ -157,10 +159,10 @@ CancellationToken cancellationToken
157159
158160 try
159161 {
160- Win32PInvoke . FileTimeToSystemTime ( ref findData . ftLastWriteTime , out Win32PInvoke . SYSTEMTIME systemModifiedTimeOutput ) ;
162+ FileTimeToSystemTime ( ref findData . ftLastWriteTime , out NativeFindStorageItemHelper . SYSTEMTIME systemModifiedTimeOutput ) ;
161163 itemModifiedDate = systemModifiedTimeOutput . ToDateTime ( ) ;
162164
163- Win32PInvoke . FileTimeToSystemTime ( ref findData . ftCreationTime , out Win32PInvoke . SYSTEMTIME systemCreatedTimeOutput ) ;
165+ FileTimeToSystemTime ( ref findData . ftCreationTime , out NativeFindStorageItemHelper . SYSTEMTIME systemCreatedTimeOutput ) ;
164166 itemCreatedDate = systemCreatedTimeOutput . ToDateTime ( ) ;
165167 }
166168 catch ( ArgumentException )
@@ -220,7 +222,7 @@ CancellationToken cancellationToken
220222 }
221223
222224 public static async Task < ListedItem > GetFile (
223- Win32PInvoke . WIN32_FIND_DATA findData ,
225+ NativeFindStorageItemHelper . WIN32_FIND_DATA findData ,
224226 string pathRoot ,
225227 bool isGitRepo ,
226228 CancellationToken cancellationToken
@@ -233,13 +235,13 @@ CancellationToken cancellationToken
233235
234236 try
235237 {
236- Win32PInvoke . FileTimeToSystemTime ( ref findData . ftLastWriteTime , out Win32PInvoke . SYSTEMTIME systemModifiedDateOutput ) ;
238+ FileTimeToSystemTime ( ref findData . ftLastWriteTime , out NativeFindStorageItemHelper . SYSTEMTIME systemModifiedDateOutput ) ;
237239 itemModifiedDate = systemModifiedDateOutput . ToDateTime ( ) ;
238240
239- Win32PInvoke . FileTimeToSystemTime ( ref findData . ftCreationTime , out Win32PInvoke . SYSTEMTIME systemCreatedDateOutput ) ;
241+ FileTimeToSystemTime ( ref findData . ftCreationTime , out NativeFindStorageItemHelper . SYSTEMTIME systemCreatedDateOutput ) ;
240242 itemCreatedDate = systemCreatedDateOutput . ToDateTime ( ) ;
241243
242- Win32PInvoke . FileTimeToSystemTime ( ref findData . ftLastAccessTime , out Win32PInvoke . SYSTEMTIME systemLastAccessOutput ) ;
244+ FileTimeToSystemTime ( ref findData . ftLastAccessTime , out NativeFindStorageItemHelper . SYSTEMTIME systemLastAccessOutput ) ;
243245 itemLastAccessDate = systemLastAccessOutput . ToDateTime ( ) ;
244246 }
245247 catch ( ArgumentException )
@@ -270,12 +272,12 @@ CancellationToken cancellationToken
270272
271273 // https://learn.microsoft.com/openspecs/windows_protocols/ms-fscc/c8e77b37-3909-4fe6-a4ea-2b9d423b1ee4
272274 bool isReparsePoint = ( ( FileAttributes ) findData . dwFileAttributes & FileAttributes . ReparsePoint ) == FileAttributes . ReparsePoint ;
273- bool isSymlink = isReparsePoint && findData . dwReserved0 == Win32PInvoke . IO_REPARSE_TAG_SYMLINK ;
275+ bool isSymlink = isReparsePoint && findData . dwReserved0 == NativeFileOperationsHelper . IO_REPARSE_TAG_SYMLINK ;
274276
275- if ( isSymlink && ! isGitRepo )
277+ if ( isSymlink )
276278 {
277279 var targetPath = Win32Helper . ParseSymLink ( itemPath ) ;
278-
280+
279281 return new ShortcutItem ( null )
280282 {
281283 PrimaryItemAttribute = StorageItemTypes . File ,
@@ -294,7 +296,7 @@ CancellationToken cancellationToken
294296 FileSizeBytes = itemSizeBytes ,
295297 TargetPath = targetPath ,
296298 IsSymLink = true
297- } ;
299+ } ;
298300 }
299301 else if ( FileExtensionHelpers . IsShortcutOrUrlFile ( findData . cFileName ) )
300302 {
0 commit comments