예제 #1
0
        internal static void CompressDecompressCore(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions?options, DirectoryEnumerationFilters filters, bool compress, PathFormat pathFormat)
        {
            var pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);

            if (null == options)
            {
                options = DirectoryEnumerationOptions.None;
            }

            // Traverse the source folder, processing files and folders.
            foreach (var fsei in EnumerateFileSystemEntryInfosCore <string>(null, transaction, pathLp, searchPattern, null, options | DirectoryEnumerationOptions.AsLongPath, filters, PathFormat.LongFullPath))
            {
                Device.ToggleCompressionCore(transaction, fsei, compress, PathFormat.LongFullPath);
            }

            // Compress the root directory, the given path.
            Device.ToggleCompressionCore(transaction, pathLp, compress, PathFormat.LongFullPath);
        }
예제 #2
0
 public static void CompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, DirectoryEnumerationFilters filters, PathFormat pathFormat)
 {
     CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, filters, true, pathFormat);
 }
예제 #3
0
 public static void CompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationFilters filters)
 {
     CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, null, filters, true, PathFormat.RelativePath);
 }
예제 #4
0
 public static void Compress(string path, DirectoryEnumerationOptions options, DirectoryEnumerationFilters filters, PathFormat pathFormat)
 {
     CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, filters, true, pathFormat);
 }
예제 #5
0
 public static void Compress(string path, DirectoryEnumerationFilters filters)
 {
     CompressDecompressCore(null, path, Path.WildcardStarMatchAll, null, filters, true, PathFormat.RelativePath);
 }
        public FindFileSystemEntryInfo(KernelTransaction transaction, bool isFolder, string path, string searchPattern, DirectoryEnumerationOptions?options, DirectoryEnumerationFilters customFilters, PathFormat pathFormat, Type typeOfT)
        {
            if (null == options)
            {
                throw new ArgumentNullException("options");
            }


            Transaction = transaction;

            OriginalInputPath = path;

            InputPath = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);

            IsRelativePath = !Path.IsPathRooted(OriginalInputPath, false);

            SearchPattern = searchPattern.TrimEnd(Path.TrimEndChars); // .NET behaviour.

            FileSystemObjectType = null;

            ContinueOnException = (options & DirectoryEnumerationOptions.ContinueOnException) != 0;

            AsLongPath = (options & DirectoryEnumerationOptions.AsLongPath) != 0;

            AsString         = typeOfT == typeof(string);
            AsFileSystemInfo = !AsString && (typeOfT == typeof(FileSystemInfo) || typeOfT.BaseType == typeof(FileSystemInfo));

            LargeCache = (options & DirectoryEnumerationOptions.LargeCache) != 0 ? NativeMethods.UseLargeCache : NativeMethods.FIND_FIRST_EX_FLAGS.NONE;

            // Only FileSystemEntryInfo makes use of (8.3) AlternateFileName.
            FindExInfoLevel = AsString || AsFileSystemInfo || (options & DirectoryEnumerationOptions.BasicSearch) != 0 ? NativeMethods.FindexInfoLevel : NativeMethods.FINDEX_INFO_LEVELS.Standard;


            if (null != customFilters)
            {
                InclusionFilter = customFilters.InclusionFilter;

                RecursionFilter = customFilters.RecursionFilter;

                ErrorHandler = customFilters.ErrorFilter;

#if !NET35
                CancellationToken = customFilters.CancellationToken;
#endif
            }

#if !NET35
            if (null == CancellationToken)
            {
                CancellationToken = new CancellationToken();
            }
#endif


            if (isFolder)
            {
                IsDirectory = true;

                Recursive = (options & DirectoryEnumerationOptions.Recursive) != 0 || null != RecursionFilter;

                SkipReparsePoints = (options & DirectoryEnumerationOptions.SkipReparsePoints) != 0;


                // Need folders or files to enumerate.
                if ((options & DirectoryEnumerationOptions.FilesAndFolders) == 0)
                {
                    options |= DirectoryEnumerationOptions.FilesAndFolders;
                }
            }

            else
            {
                options &= ~DirectoryEnumerationOptions.Folders; // Remove enumeration of folders.
                options |= DirectoryEnumerationOptions.Files;    // Add enumeration of files.
            }


            FileSystemObjectType = (options & DirectoryEnumerationOptions.FilesAndFolders) == DirectoryEnumerationOptions.FilesAndFolders

                                   // Folders and files (null).
            ? (bool?)null

                                   // Only folders (true) or only files (false).
            : (options & DirectoryEnumerationOptions.Folders) != 0;
        }