Ejemplo n.º 1
0
        internal static FindInformationEntry FromFileSystemEntry(FileSystemEntry entry, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
        {
            switch (informationLevel)
            {
            case FindInformationLevel.SMB_INFO_STANDARD:
            {
                FindInfoStandard result = new FindInfoStandard(returnResumeKeys);
                result.CreationDateTime   = entry.CreationTime;
                result.LastAccessDateTime = entry.LastAccessTime;
                result.LastWriteDateTime  = entry.LastWriteTime;
                result.FileDataSize       = (uint)Math.Min(entry.Size, UInt32.MaxValue);
                result.AllocationSize     = (uint)Math.Min(GetAllocationSize(entry.Size), UInt32.MaxValue);
                result.Attributes         = GetFileAttributes(entry);
                result.FileName           = entry.Name;
                return(result);
            }

            case FindInformationLevel.SMB_INFO_QUERY_EA_SIZE:
            {
                FindInfoQueryEASize result = new FindInfoQueryEASize(returnResumeKeys);
                result.CreationDateTime   = entry.CreationTime;
                result.LastAccessDateTime = entry.LastAccessTime;
                result.LastWriteDateTime  = entry.LastWriteTime;
                result.FileDataSize       = (uint)Math.Min(entry.Size, UInt32.MaxValue);
                result.AllocationSize     = (uint)Math.Min(GetAllocationSize(entry.Size), UInt32.MaxValue);
                result.Attributes         = GetFileAttributes(entry);
                result.EASize             = 0;
                result.FileName           = entry.Name;
                return(result);
            }

            case FindInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST:
            {
                FindInfoQueryExtendedAttributesFromList result = new FindInfoQueryExtendedAttributesFromList(returnResumeKeys);
                result.CreationDateTime      = entry.CreationTime;
                result.LastAccessDateTime    = entry.LastAccessTime;
                result.LastWriteDateTime     = entry.LastWriteTime;
                result.FileDataSize          = (uint)Math.Min(entry.Size, UInt32.MaxValue);
                result.AllocationSize        = (uint)Math.Min(GetAllocationSize(entry.Size), UInt32.MaxValue);
                result.Attributes            = GetFileAttributes(entry);
                result.ExtendedAttributeList = new FullExtendedAttributeList();
                return(result);
            }

            case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO:
            {
                FindFileDirectoryInfo result = new FindFileDirectoryInfo();
                result.CreationTime       = entry.CreationTime;
                result.LastAccessTime     = entry.LastAccessTime;
                result.LastWriteTime      = entry.LastWriteTime;
                result.LastAttrChangeTime = entry.LastWriteTime;
                result.EndOfFile          = entry.Size;
                result.AllocationSize     = GetAllocationSize(entry.Size);
                result.ExtFileAttributes  = GetExtendedFileAttributes(entry);
                result.FileName           = entry.Name;
                return(result);
            }

            case FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO:
            {
                FindFileFullDirectoryInfo result = new FindFileFullDirectoryInfo();
                result.CreationTime       = entry.CreationTime;
                result.LastAccessTime     = entry.LastAccessTime;
                result.LastWriteTime      = entry.LastWriteTime;
                result.LastAttrChangeTime = entry.LastWriteTime;
                result.EndOfFile          = entry.Size;
                result.AllocationSize     = GetAllocationSize(entry.Size);
                result.ExtFileAttributes  = GetExtendedFileAttributes(entry);
                result.FileName           = entry.Name;
                return(result);
            }

            case FindInformationLevel.SMB_FIND_FILE_NAMES_INFO:
            {
                FindFileNamesInfo result = new FindFileNamesInfo();
                result.FileName = entry.Name;
                return(result);
            }

            case FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
            {
                FindFileBothDirectoryInfo result = new FindFileBothDirectoryInfo();
                result.CreationTime      = entry.CreationTime;
                result.LastAccessTime    = entry.LastAccessTime;
                result.LastWriteTime     = entry.LastWriteTime;
                result.LastChangeTime    = entry.LastWriteTime;
                result.EndOfFile         = entry.Size;
                result.AllocationSize    = GetAllocationSize(entry.Size);
                result.ExtFileAttributes = GetExtendedFileAttributes(entry);
                result.ShortName         = GetShortName(entry.Name);
                result.FileName          = entry.Name;
                return(result);
            }

            default:
            {
                throw new UnsupportedInformationLevelException();
            }
            }
        }
Ejemplo n.º 2
0
        /// <exception cref="SMBLibrary.UnsupportedInformationLevelException"></exception>
        public static FindInformation GetFindInformation(QueryDirectoryFileInformation entry, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
        {
            switch (informationLevel)
            {
            case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO:
            {
                FileDirectoryInformation fileDirectoryInfo = (FileDirectoryInformation)entry;

                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);
            }

            case FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO:
            {
                FileFullDirectoryInformation fileFullDirectoryInfo = (FileFullDirectoryInformation)entry;

                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);
            }

            case FindInformationLevel.SMB_FIND_FILE_NAMES_INFO:
            {
                FileNamesInformation fileNamesInfo = (FileNamesInformation)entry;

                FindFileNamesInfo result = new FindFileNamesInfo();
                result.FileIndex = fileNamesInfo.FileIndex;
                result.FileName  = fileNamesInfo.FileName;
                return(result);
            }

            case FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
            {
                FileBothDirectoryInformation fileBothDirectoryInfo = (FileBothDirectoryInformation)entry;

                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);
            }

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