コード例 #1
0
ファイル: CliVolumeFile.cs プロジェクト: apollo-voyage/ksc
 public CliVolumeFile(CliVolume volume, FileInfo fileInfo, VolumePath path)
     : base(volume, path)
 {
     this.fileInfo = fileInfo;
 }
コード例 #2
0
        private static HarddiskDirectory ToHarddiskDirectory(this ConfigNode configNode, Harddisk harddisk, VolumePath path)
        {
            HarddiskDirectory directory = new HarddiskDirectory(harddisk, path);

            foreach (ConfigNode fileNode in configNode.GetNodes("file"))
            {
                directory.CreateFile(fileNode.GetValue(FilenameValueString), fileNode.ToHarddiskFile(harddisk, directory));
            }

            foreach (ConfigNode dirNode in configNode.GetNodes("directory"))
            {
                string dirName = dirNode.GetValue(DirnameValueString);

                directory.CreateDirectory(dirName, dirNode.ToHarddiskDirectory(harddisk, VolumePath.FromString(dirName, path)));
            }

            return(directory);
        }
コード例 #3
0
        private void InitUI()
        {
            //Populate selector for boot scripts
            BaseField field   = Fields["bootFile"];
            var       options = (UI_ChooseOption)field.uiControlEditor;

            var bootFiles = new List <VolumePath>();

            bootFiles.AddRange(BootDirectoryFiles());

            //no need to show the control if there are no available boot files
            options.controlEnabled = bootFiles.Count >= 1;
            field.guiActiveEditor  = bootFiles.Count >= 1;
            var availableOptions  = bootFiles.Select(e => e.ToString()).ToList();
            var availableDisplays = bootFiles.Select(e => e.Name).ToList();

            availableOptions.Insert(0, "None");
            availableDisplays.Insert(0, "None");

            var bootFilePath = BootFilePath; // store the selected path temporarily

            if (bootFilePath != null && !bootFiles.Contains(bootFilePath))
            {
                // if the path is not null ("None", null, or empty) and if it isn't in list of files
                var archive = new Archive(SafeHouse.ArchiveFolder);
                var file    = archive.Open(bootFilePath) as VolumeFile; // try to open the file as saved
                if (file == null)
                {
                    // check the same file name, but in the boot directory.
                    var path = VolumePath.FromString(BootDirectoryName).Combine(bootFilePath.Name);
                    file = archive.Open(path) as VolumeFile; // try to open the new path
                    if (file == null)
                    {
                        // try the file name without "boot" prefix
                        var name = bootFilePath.Name;
                        if (name.StartsWith("boot", StringComparison.OrdinalIgnoreCase) && name.Length > 4)
                        {
                            // strip the boot prefix and try that file name
                            name = name.Substring(4);
                            path = VolumePath.FromString(BootDirectoryName).Combine(name);
                            file = name.StartsWith(".") ? null : archive.Open(path) as VolumeFile;  // try to open the new path
                            if (file == null)
                            {
                                // try the file name without "boot_" prefix
                                if (name.StartsWith("_", StringComparison.OrdinalIgnoreCase) && name.Length > 1)
                                {
                                    // only need to strip "_" here
                                    name = name.Substring(1);
                                    path = VolumePath.FromString(BootDirectoryName).Combine(name);
                                    file = name.StartsWith(".") ? null : archive.Open(path) as VolumeFile;  // try to open the new path
                                }
                            }
                        }
                    }
                }

                // now, if we have a file object, use its values.
                if (file != null)
                {
                    // store the boot file information
                    bootFile = file.Path.ToString();
                    if (!bootFiles.Contains(file.Path))
                    {
                        availableOptions.Insert(1, bootFile);
                        availableDisplays.Insert(1, "*" + file.Path.Name); // "*" is indication the file is not normally available
                    }
                }
            }
            SafeHouse.Logger.SuperVerbose("bootFile: " + bootFile);

            options.options = availableOptions.ToArray();
            options.display = availableDisplays.ToArray();

            //populate diskSpaceUI selector
            diskSpaceUI = diskSpace.ToString();
            field       = Fields["diskSpaceUI"];
            options     = (UI_ChooseOption)field.uiControlEditor;
            var sizeOptions = new string[3];

            sizeOptions[0]  = baseDiskSpace.ToString();
            sizeOptions[1]  = (baseDiskSpace * 2).ToString();
            sizeOptions[2]  = (baseDiskSpace * 4).ToString();
            options.options = sizeOptions;
        }
コード例 #4
0
 public HarddiskFile(HarddiskDirectory harddiskDirectory, string name) : base(harddiskDirectory.Volume as Harddisk,
                                                                              VolumePath.FromString(name, harddiskDirectory.Path))
 {
     this.hardiskDirectory = harddiskDirectory;
 }
コード例 #5
0
ファイル: PathValue.cs プロジェクト: stephengeorgewest/KOS-1
 public PathValue FromPath(VolumePath volumePath, string volumeId)
 {
     return(new PathValue(GlobalPath.FromVolumePath(volumePath, volumeId), sharedObjects));
 }
コード例 #6
0
 public void CanHandlePathsThatPointOutside2()
 {
     VolumePath.FromString("/../test/test/test");
 }
コード例 #7
0
 public override bool Exists(VolumePath path, bool ksmDefault = false)
 {
     return(Search(path, ksmDefault) != null);
 }
コード例 #8
0
        public void CanHandleAbsolutePathWithParent()
        {
            VolumePath parent = VolumePath.FromString("/parent");

            VolumePath.FromString("/identifier", parent);
        }
コード例 #9
0
 public void CanHandlePathsThatPointOutside1()
 {
     VolumePath.FromString("/..");
 }
コード例 #10
0
ファイル: MockVolume.cs プロジェクト: cahe7cb/kostools
 public override VolumeFile SaveFile(VolumePath path, FileContent content, bool verifyFreeSpace = true)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
ファイル: MockVolume.cs プロジェクト: cahe7cb/kostools
 public override VolumeItem Open(VolumePath path, bool ksmDefault = false)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
ファイル: MockVolume.cs プロジェクト: cahe7cb/kostools
 public override bool Exists(VolumePath path, bool ksmDefault = false)
 {
     throw new NotImplementedException();
 }
コード例 #13
0
ファイル: MockVolume.cs プロジェクト: cahe7cb/kostools
 public override VolumeFile CreateFile(VolumePath path)
 {
     throw new NotImplementedException();
 }
コード例 #14
0
ファイル: MockVolume.cs プロジェクト: cahe7cb/kostools
 public override VolumeDirectory CreateDirectory(VolumePath path)
 {
     throw new NotImplementedException();
 }