Exemple #1
0
        protected override ExitCode ExecuteFileTask()
        {
            VolumeInformation info = ExtendedFileService.GetVolumeInformation(Arguments.Target);

            Table table = Table.Create(new ColumnFormat(1, ContentVisibility.ShowAll, Justification.Right), new ColumnFormat(1));

            table.HasHeader = false;
            table.AddRow("Volume Name", info.VolumeName);
            table.AddRow("Serial Number", info.VolumeSerialNumber.ToString());
            table.AddRow("Max Component Length", info.MaximumComponentLength.ToString());
            table.AddRow("File System Name", info.FileSystemName.ToString());
            foreach (var value in Enum.GetValues(typeof(FileSystemFeature)))
            {
                FileSystemFeature feature = (FileSystemFeature)value;
                if ((feature & info.FileSystemFlags) == feature)
                {
                    table.AddRow(feature.ToString(), "true");
                }
                else
                {
                    table.AddRow(feature.ToString(), "false");
                }
            }

            this.Loggers[LoggerType.Result].Write(table);
            return(ExitCode.Success);
        }
Exemple #2
0
        protected override ExitCode ExecuteFileTask()
        {
            foreach (var stream in ExtendedFileService.GetAlternateStreamInformation(GetFullTargetPath()))
            {
                ResultLog.WriteLine($"Stream '{stream.Name}', Size {stream.Size}");
            }

            return(ExitCode.Success);
        }
Exemple #3
0
        protected override ExitCode ExecuteFileTask()
        {
            foreach (string pathName in ExtendedFileService.GetVolumeMountPoints(this.Arguments.Target))
            {
                this.Loggers[LoggerType.Result].WriteLine(pathName);
            }

            return(ExitCode.Success);
        }
        protected override ExitCode ExecuteFileTask()
        {
            foreach (string drive in ExtendedFileService.GetLogicalDriveStrings())
            {
                this.Loggers[LoggerType.Result].WriteLine(drive);
            }

            return(ExitCode.Success);
        }
Exemple #5
0
 static FlexServiceProvider()
 {
     concreteServices = new SimpleServiceProvider();
     var extendedFileService = new ExtendedFileService();
     concreteServices.AddService<IExtendedFileService>(extendedFileService);
     concreteServices.AddService<IFileService>(new FileService(extendedFileService));
     concreteServices.AddService<IConsoleService>(new ConcreteConsoleService());
     concreteServices.AddService<IConfigurationManager>(new ConfigurationManager());
 }
        static FlexServiceProvider()
        {
            _concreteServices = new SimpleServiceProvider();
            var extendedFileService = new ExtendedFileService();

            _concreteServices.AddService <IExtendedFileService>(extendedFileService);
            _concreteServices.AddService <IFileService>(new FileService(extendedFileService));
            _concreteServices.AddService <IConsoleService>(new ConcreteConsoleService());
            _concreteServices.AddService <IConfigurationManager>(new ConfigurationManager());
        }
Exemple #7
0
        protected override ExitCode ExecuteFileTask()
        {
            string target = Arguments.Target;

            if (target == null)
            {
                target = ".";
            }

            string fullPath = ExtendedFileService.GetFinalPath(GetFullPath(target));

            FileService.CurrentDirectory = fullPath;
            ResultLog.WriteLine(FileService.CurrentDirectory);

            return(ExitCode.Success);
        }
Exemple #8
0
        public void FinalPathNameLinkBehavior()
        {
            var extendedFileService = new ExtendedFileService();

            if (!extendedFileService.CanCreateSymbolicLinks())
            {
                return;
            }

            // GetFinalPathName always points to the linked file unless you specifically open the reparse point
            using (var cleaner = new TestFileCleaner())
            {
                string filePath     = Paths.Combine(cleaner.TempFolder, "Target");
                string extendedPath = Paths.AddExtendedPrefix(filePath, addIfUnderLegacyMaxPath: true);

                cleaner.FileService.WriteAllText(filePath, "CreateSymbolicLinkToFile");

                string symbolicLink = Paths.Combine(cleaner.TempFolder, "Link");
                string extendedLink = Paths.AddExtendedPrefix(symbolicLink, addIfUnderLegacyMaxPath: true);
                NativeMethods.FileManagement.CreateSymbolicLink(symbolicLink, filePath);
                NativeMethods.FileManagement.FileExists(symbolicLink).Should().BeTrue("symbolic link should exist");

                // GetFinalPathName should normalize the casing, pushing ToUpper to validate
                using (var handle = NativeMethods.FileManagement.CreateFile(symbolicLink.ToUpperInvariant(), FileAccess.Read, FileShare.ReadWrite, FileMode.Open, 0))
                {
                    handle.IsInvalid.Should().BeFalse();
                    NativeMethods.FileManagement.GetFinalPathName(handle, NativeMethods.FileManagement.FinalPathFlags.FILE_NAME_NORMALIZED)
                    .Should().Be(extendedPath);
                    NativeMethods.FileManagement.GetFinalPathName(handle, NativeMethods.FileManagement.FinalPathFlags.FILE_NAME_OPENED)
                    .Should().Be(extendedPath);
                }

                using (var handle = NativeMethods.FileManagement.CreateFile(symbolicLink.ToUpperInvariant(), FileAccess.Read, FileShare.ReadWrite, FileMode.Open, NativeMethods.FileManagement.AllFileAttributeFlags.FILE_FLAG_OPEN_REPARSE_POINT))
                {
                    handle.IsInvalid.Should().BeFalse();
                    NativeMethods.FileManagement.GetFinalPathName(handle, NativeMethods.FileManagement.FinalPathFlags.FILE_NAME_NORMALIZED)
                    .Should().Be(extendedLink);
                    NativeMethods.FileManagement.GetFinalPathName(handle, NativeMethods.FileManagement.FinalPathFlags.FILE_NAME_OPENED)
                    .Should().Be(extendedLink);
                }
            }
        }
Exemple #9
0
        protected override ExitCode ExecuteFileTask()
        {
            string target = this.Arguments.Target;

            target = String.IsNullOrWhiteSpace(target) ? null : target;

            var targetPaths =
                from path in ExtendedFileService.QueryDosDeviceNames(target)
                orderby path
                select path;

            int count = 0;

            foreach (string path in targetPaths)
            {
                count++;
                this.Loggers[LoggerType.Result].WriteLine(path);
            }

            this.Loggers[LoggerType.Status].WriteLine("\nFound {0} paths", count);

            return(ExitCode.Success);
        }
Exemple #10
0
 protected override ExitCode ExecuteFileTask()
 {
     this.Loggers[LoggerType.Result].WriteLine(ExtendedFileService.GetMountPoint(GetFullTargetPath()));
     return(ExitCode.Success);
 }
Exemple #11
0
        protected override ExitCode ExecuteFileTask()
        {
            ResultLog.WriteLine(ExtendedFileService.GetVolumeName(Arguments.Target));

            return(ExitCode.Success);
        }
Exemple #12
0
 protected override ExitCode ExecuteFileTask()
 {
     ResultLog.WriteLine(ExtendedFileService.GetShortPath(GetFullTargetPath()));
     return(ExitCode.Success);
 }
Exemple #13
0
        public void FinalPathNameLinkBehavior()
        {
            var extendedFileService = new ExtendedFileService();
            if (!extendedFileService.CanCreateSymbolicLinks()) return;

            // GetFinalPathName always points to the linked file unless you specifically open the reparse point
            using (var cleaner = new TestFileCleaner())
            {
                string filePath = Paths.Combine(cleaner.TempFolder, "Target");
                string extendedPath = Paths.AddExtendedPrefix(filePath, addIfUnderLegacyMaxPath: true);

                cleaner.FileService.WriteAllText(filePath, "CreateSymbolicLinkToFile");

                string symbolicLink = Paths.Combine(cleaner.TempFolder, "Link");
                string extendedLink = Paths.AddExtendedPrefix(symbolicLink, addIfUnderLegacyMaxPath: true);
                NativeMethods.FileManagement.CreateSymbolicLink(symbolicLink, filePath);
                NativeMethods.FileManagement.FileExists(symbolicLink).Should().BeTrue("symbolic link should exist");

                // GetFinalPathName should normalize the casing, pushing ToUpper to validate
                using (var handle = NativeMethods.FileManagement.CreateFile(symbolicLink.ToUpperInvariant(), FileAccess.Read, FileShare.ReadWrite, FileMode.Open, 0))
                {
                    handle.IsInvalid.Should().BeFalse();
                    NativeMethods.FileManagement.GetFinalPathName(handle, NativeMethods.FileManagement.FinalPathFlags.FILE_NAME_NORMALIZED)
                        .Should().Be(extendedPath);
                    NativeMethods.FileManagement.GetFinalPathName(handle, NativeMethods.FileManagement.FinalPathFlags.FILE_NAME_OPENED)
                        .Should().Be(extendedPath);
                }

                using (var handle = NativeMethods.FileManagement.CreateFile(symbolicLink.ToUpperInvariant(), FileAccess.Read, FileShare.ReadWrite, FileMode.Open, NativeMethods.FileManagement.AllFileAttributeFlags.FILE_FLAG_OPEN_REPARSE_POINT))
                {
                    handle.IsInvalid.Should().BeFalse();
                    NativeMethods.FileManagement.GetFinalPathName(handle, NativeMethods.FileManagement.FinalPathFlags.FILE_NAME_NORMALIZED)
                        .Should().Be(extendedLink);
                    NativeMethods.FileManagement.GetFinalPathName(handle, NativeMethods.FileManagement.FinalPathFlags.FILE_NAME_OPENED)
                        .Should().Be(extendedLink);
                }
            }
        }
Exemple #14
0
        protected override ExitCode ExecuteFileTask()
        {
            Loggers[LoggerType.Result].WriteLine(ExtendedFileService.GetDriveLetter(this.FileService, GetFullTargetPath()));

            return(ExitCode.Success);
        }