Exemple #1
0
        /// <summary>Constructs the <see cref="FileItemBase"/> with a <see cref="IScanFileInfo"/>.</summary>
        ///
        /// <param name="info">The file information.</param>
        /// <param name="type">The type of the item.</param>
        /// <param name="flags">The flags for the item (except <see cref="FileAttributes"/>).</param>
        private protected FileItemBase(IScanFileInfo info, FileItemType type, FileItemFlags flags)
            : this(info.Name, type, flags)
        {
            LastWriteTimeUtc = info.LastWriteTimeUtc;
            Attributes       = info.Attributes;

            if (!info.IsDirectory && !info.IsSymbolicLink)
            {
                Size = info.Size;
            }
        }
Exemple #2
0
 /// <summary>Enables or disables the specified flag.</summary>
 ///
 /// <param name="flags">The flags to modify</param>
 /// <param name="flag">The flag(s) to set.</param>
 /// <param name="value">True if the flags should be set</param>
 /// <returns>The modified flags.</returns>
 public static FileItemFlags SetFlag(this FileItemFlags flags, FileItemFlags flag, bool value)
 {
     if (value)
     {
         return(flags | flag);
     }
     else
     {
         return(flags & ~flag);
     }
 }
Exemple #3
0
        /// <summary>Constructs the <see cref="FileItemBase"/> without any file info.</summary>
        ///
        /// <param name="name">The name of the item.</param>
        /// <param name="type">The type of the item.</param>
        /// <param name="flags">The flags for the item (except <see cref="FileAttributes"/>).</param>
        private protected FileItemBase(string name, FileItemType type, FileItemFlags flags)
        {
            if (flags != FileItemFlags.None)
            {
                this.flags |= (flags & FileItemFlags.TypeFlagsMask);
            }
            if (type == FileItemType.Volume)
            {
                name = PathUtils.AddDirectorySeparator(name);
            }

            Name   = name;
            Type   = type;
            state |= FileItemStates.Exists;
        }
Exemple #4
0
        /// <summary>Constructs the <see cref="FileItemBase"/> with a <see cref="FileSystemInfo"/>.</summary>
        ///
        /// <param name="info">The file information.</param>
        /// <param name="type">The type of the item.</param>
        /// <param name="flags">The flags for the item (except <see cref="FileAttributes"/>).</param>
        private protected FileItemBase(FileSystemInfo info, FileItemType type, FileItemFlags flags)
            : this(info.Name, type, flags)
        {
            LastWriteTimeUtc = info.LastWriteTimeUtc;
            Attributes       = info.Attributes;

            if (!info.Attributes.HasFlag(FileAttributes.Directory) &&
                !info.Attributes.HasFlag(FileAttributes.ReparsePoint) &&
                info is FileInfo fileInfo)
            {
                Size = fileInfo.Length;
            }

            if (!info.Exists)
            {
                state           &= ~FileItemStates.Exists;
                Attributes       = 0;
                LastWriteTimeUtc = DateTime.MinValue;
            }
        }