Пример #1
0
        private void CheckData(IntPtr dataPtr, List <FsItem> items, ref long processed)
        {
            var info = new FILE_DIRECTORY_INFORMATION();

            do
            {
                Marshal.PtrToStructure(dataPtr, info);
                if ((info.FileAttributes & CreateFileOptions.FILE_ATTRIBUTE_REPARSE_POINT) == 0 || //not symlink
                    (info.FileAttributes & CreateFileOptions.FILE_ATTRIBUTE_OFFLINE) != 0)    //or symlink to offline file
                {
                    var name  = Marshal.PtrToStringUni(dataPtr + FileNameOffset, (int)info.FileNameLength / 2);
                    var isDir = (info.FileAttributes & CreateFileOptions.FILE_ATTRIBUTE_DIRECTORY) > 0;
                    if (!(isDir && ((name.Length == 1 && name[0] == '.') || (name.Length == 2 && name[0] == '.' && name[1] == '.')))) //not "." or ".." pseudo-directories
                    {
                        long size = PreferAllocatedSize ? info.AllocationSize.QuadPart : info.EndOfFile.QuadPart;
                        items.Add(new FsItem(name, size, isDir, info.LastWriteTime.QuadPart));
                        processed += size;
                    }
                }
                dataPtr += (int)info.NextEntryOffset;
            } while (info.NextEntryOffset != 0);
        }
Пример #2
0
 private static void CheckData(IntPtr dataPtr, List<FsItem> items, ref long processed)
 {
     var info = new FILE_DIRECTORY_INFORMATION();
     var structSize = Marshal.SizeOf(info);
     do
     {
         Marshal.PtrToStructure(dataPtr, info);
         if ((info.FileAttributes & CreateFileOptions.FILE_ATTRIBUTE_REPARSE_POINT) == 0 //not symlink
             || (info.FileAttributes & CreateFileOptions.FILE_ATTRIBUTE_OFFLINE) != 0) //or symlink to offline file
         {
             var name = Marshal.PtrToStringUni(dataPtr + structSize - 2, (int) info.FileNameLength/2);
             items.Add(new FsItem(name,
                                  info.AllocationSize.QuadPart,
                                  (info.FileAttributes & CreateFileOptions.FILE_ATTRIBUTE_DIRECTORY) > 0));
             processed += info.AllocationSize.QuadPart;
         }
         dataPtr += (int) info.NextEntryOffset;
     } while (info.NextEntryOffset != 0);
 }