public CliVolumeFile(CliVolume volume, FileInfo fileInfo, VolumePath path) : base(volume, path) { this.fileInfo = fileInfo; }
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); }
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; }
public HarddiskFile(HarddiskDirectory harddiskDirectory, string name) : base(harddiskDirectory.Volume as Harddisk, VolumePath.FromString(name, harddiskDirectory.Path)) { this.hardiskDirectory = harddiskDirectory; }
public PathValue FromPath(VolumePath volumePath, string volumeId) { return(new PathValue(GlobalPath.FromVolumePath(volumePath, volumeId), sharedObjects)); }
public void CanHandlePathsThatPointOutside2() { VolumePath.FromString("/../test/test/test"); }
public override bool Exists(VolumePath path, bool ksmDefault = false) { return(Search(path, ksmDefault) != null); }
public void CanHandleAbsolutePathWithParent() { VolumePath parent = VolumePath.FromString("/parent"); VolumePath.FromString("/identifier", parent); }
public void CanHandlePathsThatPointOutside1() { VolumePath.FromString("/.."); }
public override VolumeFile SaveFile(VolumePath path, FileContent content, bool verifyFreeSpace = true) { throw new NotImplementedException(); }
public override VolumeItem Open(VolumePath path, bool ksmDefault = false) { throw new NotImplementedException(); }
public override bool Exists(VolumePath path, bool ksmDefault = false) { throw new NotImplementedException(); }
public override VolumeFile CreateFile(VolumePath path) { throw new NotImplementedException(); }
public override VolumeDirectory CreateDirectory(VolumePath path) { throw new NotImplementedException(); }