/// <summary>
 /// Verify FileIdFullDirectoryInformation entry
 /// </summary>
 private void VerifyFileInformation(FileIdFullDirectoryInformation entry, int index, string fileName, FileAttribute fileAttribute, long endofFile, long allocationSize, uint eaSize)
 {
     Site.Log.Add(LogEntryKind.Debug, $"Start to verify entry {index}.");
     VerifyFileCommonDirectoryInformation(entry.FileCommonDirectoryInformation, fileAttribute);
     Site.Assert.AreEqual(fileName, Encoding.Unicode.GetString(entry.FileName), $"FileName of the entry should be {fileName}.");
     Site.Assert.AreEqual(endofFile, entry.FileCommonDirectoryInformation.EndOfFile, "The EndOfFile of the entry should be 0.");
     Site.Assert.AreEqual(allocationSize, entry.FileCommonDirectoryInformation.AllocationSize, "The AllocationSize of the entry should be 0.");
     Site.Assert.AreEqual(eaSize, entry.EaSize, $"EaSize of the entry should be {eaSize}.");
 }
Esempio n. 2
0
 /// <exception cref="SmbLibraryStd.UnsupportedInformationLevelException"></exception>
 public static FindInformation ToFindInformation(QueryDirectoryFileInformation fileInformation)
 {
     if (fileInformation is FileDirectoryInformation)
     {
         FileDirectoryInformation fileDirectoryInfo = (FileDirectoryInformation)fileInformation;
         FindFileDirectoryInfo    result            = new FindFileDirectoryInfo();
         result.FileIndex          = fileDirectoryInfo.FileIndex;
         result.CreationTime       = fileDirectoryInfo.CreationTime;
         result.LastAccessTime     = fileDirectoryInfo.LastAccessTime;
         result.LastWriteTime      = fileDirectoryInfo.LastWriteTime;
         result.LastAttrChangeTime = fileDirectoryInfo.LastWriteTime;
         result.EndOfFile          = fileDirectoryInfo.EndOfFile;
         result.AllocationSize     = fileDirectoryInfo.AllocationSize;
         result.ExtFileAttributes  = (ExtendedFileAttributes)fileDirectoryInfo.FileAttributes;
         result.FileName           = fileDirectoryInfo.FileName;
         return(result);
     }
     else if (fileInformation is FileFullDirectoryInformation)
     {
         FileFullDirectoryInformation fileFullDirectoryInfo = (FileFullDirectoryInformation)fileInformation;
         FindFileFullDirectoryInfo    result = new FindFileFullDirectoryInfo();
         result.FileIndex          = fileFullDirectoryInfo.FileIndex;
         result.CreationTime       = fileFullDirectoryInfo.CreationTime;
         result.LastAccessTime     = fileFullDirectoryInfo.LastAccessTime;
         result.LastWriteTime      = fileFullDirectoryInfo.LastWriteTime;
         result.LastAttrChangeTime = fileFullDirectoryInfo.LastWriteTime;
         result.EndOfFile          = fileFullDirectoryInfo.EndOfFile;
         result.AllocationSize     = fileFullDirectoryInfo.AllocationSize;
         result.ExtFileAttributes  = (ExtendedFileAttributes)fileFullDirectoryInfo.FileAttributes;
         result.EASize             = fileFullDirectoryInfo.EaSize;
         result.FileName           = fileFullDirectoryInfo.FileName;
         return(result);
     }
     else if (fileInformation is FileNamesInformation)
     {
         FileNamesInformation fileNamesInfo = (FileNamesInformation)fileInformation;
         FindFileNamesInfo    result        = new FindFileNamesInfo();
         result.FileIndex = fileNamesInfo.FileIndex;
         result.FileName  = fileNamesInfo.FileName;
         return(result);
     }
     else if (fileInformation is FileBothDirectoryInformation)
     {
         FileBothDirectoryInformation fileBothDirectoryInfo = (FileBothDirectoryInformation)fileInformation;
         FindFileBothDirectoryInfo    result = new FindFileBothDirectoryInfo();
         result.FileIndex         = fileBothDirectoryInfo.FileIndex;
         result.CreationTime      = fileBothDirectoryInfo.CreationTime;
         result.LastAccessTime    = fileBothDirectoryInfo.LastAccessTime;
         result.LastWriteTime     = fileBothDirectoryInfo.LastWriteTime;
         result.LastChangeTime    = fileBothDirectoryInfo.LastWriteTime;
         result.EndOfFile         = fileBothDirectoryInfo.EndOfFile;
         result.AllocationSize    = fileBothDirectoryInfo.AllocationSize;
         result.ExtFileAttributes = (ExtendedFileAttributes)fileBothDirectoryInfo.FileAttributes;
         result.EASize            = fileBothDirectoryInfo.EaSize;
         result.Reserved          = fileBothDirectoryInfo.Reserved;
         result.ShortName         = fileBothDirectoryInfo.ShortName;
         result.FileName          = fileBothDirectoryInfo.FileName;
         return(result);
     }
     else if (fileInformation is FileIdFullDirectoryInformation)
     {
         FileIdFullDirectoryInformation fileIDFullDirectoryInfo = (FileIdFullDirectoryInformation)fileInformation;
         FindFileIDFullDirectoryInfo    result = new FindFileIDFullDirectoryInfo();
         result.FileIndex          = fileIDFullDirectoryInfo.FileIndex;
         result.CreationTime       = fileIDFullDirectoryInfo.CreationTime;
         result.LastAccessTime     = fileIDFullDirectoryInfo.LastAccessTime;
         result.LastWriteTime      = fileIDFullDirectoryInfo.LastWriteTime;
         result.LastAttrChangeTime = fileIDFullDirectoryInfo.LastWriteTime;
         result.EndOfFile          = fileIDFullDirectoryInfo.EndOfFile;
         result.AllocationSize     = fileIDFullDirectoryInfo.AllocationSize;
         result.ExtFileAttributes  = (ExtendedFileAttributes)fileIDFullDirectoryInfo.FileAttributes;
         result.EASize             = fileIDFullDirectoryInfo.EaSize;
         result.Reserved           = fileIDFullDirectoryInfo.Reserved;
         result.FileID             = fileIDFullDirectoryInfo.FileId;
         result.FileName           = fileIDFullDirectoryInfo.FileName;
         return(result);
     }
     else if (fileInformation is FileIdBothDirectoryInformation)
     {
         FileIdBothDirectoryInformation fileIDBothDirectoryInfo = (FileIdBothDirectoryInformation)fileInformation;
         FindFileIDBothDirectoryInfo    result = new FindFileIDBothDirectoryInfo();
         result.FileIndex         = fileIDBothDirectoryInfo.FileIndex;
         result.CreationTime      = fileIDBothDirectoryInfo.CreationTime;
         result.LastAccessTime    = fileIDBothDirectoryInfo.LastAccessTime;
         result.LastWriteTime     = fileIDBothDirectoryInfo.LastWriteTime;
         result.LastChangeTime    = fileIDBothDirectoryInfo.LastWriteTime;
         result.EndOfFile         = fileIDBothDirectoryInfo.EndOfFile;
         result.AllocationSize    = fileIDBothDirectoryInfo.AllocationSize;
         result.ExtFileAttributes = (ExtendedFileAttributes)fileIDBothDirectoryInfo.FileAttributes;
         result.EASize            = fileIDBothDirectoryInfo.EaSize;
         result.Reserved          = fileIDBothDirectoryInfo.Reserved1;
         result.ShortName         = fileIDBothDirectoryInfo.ShortName;
         result.Reserved2         = fileIDBothDirectoryInfo.Reserved2;
         result.FileID            = fileIDBothDirectoryInfo.FileId;
         result.FileName          = fileIDBothDirectoryInfo.FileName;
         return(result);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Esempio n. 3
0
        private static QueryDirectoryFileInformation FromFileSystemEntry(FileSystemEntry entry, FileInformationClass informationClass)
        {
            switch (informationClass)
            {
            case FileInformationClass.FileBothDirectoryInformation:
            {
                FileBothDirectoryInformation result = new FileBothDirectoryInformation();
                result.CreationTime   = entry.CreationTime;
                result.LastAccessTime = entry.LastAccessTime;
                result.LastWriteTime  = entry.LastWriteTime;
                result.ChangeTime     = entry.LastWriteTime;
                result.EndOfFile      = (long)entry.Size;
                result.AllocationSize = (long)GetAllocationSize(entry.Size);
                result.FileAttributes = GetFileAttributes(entry);
                result.EaSize         = 0;
                result.FileName       = entry.Name;
                return(result);
            }

            case FileInformationClass.FileDirectoryInformation:
            {
                FileDirectoryInformation result = new FileDirectoryInformation();
                result.CreationTime   = entry.CreationTime;
                result.LastAccessTime = entry.LastAccessTime;
                result.LastWriteTime  = entry.LastWriteTime;
                result.ChangeTime     = entry.LastWriteTime;
                result.EndOfFile      = (long)entry.Size;
                result.AllocationSize = (long)GetAllocationSize(entry.Size);
                result.FileAttributes = GetFileAttributes(entry);
                result.FileName       = entry.Name;
                return(result);
            }

            case FileInformationClass.FileFullDirectoryInformation:
            {
                FileFullDirectoryInformation result = new FileFullDirectoryInformation();
                result.CreationTime   = entry.CreationTime;
                result.LastAccessTime = entry.LastAccessTime;
                result.LastWriteTime  = entry.LastWriteTime;
                result.ChangeTime     = entry.LastWriteTime;
                result.EndOfFile      = (long)entry.Size;
                result.AllocationSize = (long)GetAllocationSize(entry.Size);
                result.FileAttributes = GetFileAttributes(entry);
                result.EaSize         = 0;
                result.FileName       = entry.Name;
                return(result);
            }

            case FileInformationClass.FileIdBothDirectoryInformation:
            {
                FileIdBothDirectoryInformation result = new FileIdBothDirectoryInformation();
                result.CreationTime   = entry.CreationTime;
                result.LastAccessTime = entry.LastAccessTime;
                result.LastWriteTime  = entry.LastWriteTime;
                result.ChangeTime     = entry.LastWriteTime;
                result.EndOfFile      = (long)entry.Size;
                result.AllocationSize = (long)GetAllocationSize(entry.Size);
                result.FileAttributes = GetFileAttributes(entry);
                result.EaSize         = 0;
                result.FileId         = 0;
                result.FileName       = entry.Name;
                return(result);
            }

            case FileInformationClass.FileIdFullDirectoryInformation:
            {
                FileIdFullDirectoryInformation result = new FileIdFullDirectoryInformation();
                result.CreationTime   = entry.CreationTime;
                result.LastAccessTime = entry.LastAccessTime;
                result.LastWriteTime  = entry.LastWriteTime;
                result.ChangeTime     = entry.LastWriteTime;
                result.EndOfFile      = (long)entry.Size;
                result.AllocationSize = (long)GetAllocationSize(entry.Size);
                result.FileAttributes = GetFileAttributes(entry);
                result.EaSize         = 0;
                result.FileId         = 0;
                result.FileName       = entry.Name;
                return(result);
            }

            case FileInformationClass.FileNamesInformation:
            {
                FileNamesInformation result = new FileNamesInformation();
                result.FileName = entry.Name;
                return(result);
            }

            default:
            {
                throw new UnsupportedInformationLevelException();
            }
            }
        }