private void SaveDisk(VirtualDisk disk, ProgressHandler handler) { if (disk.FileName == null && disk is VirtualHardDisk) { disk.FileName = GetNewDiskPath (); } if (!File.Exists (disk.FileName) && disk is VirtualHardDisk) { VirtualHardDisk hd = disk as VirtualHardDisk; if (hd.BusType == DiskBusType.Scsi) { hd.ScsiDeviceType = OperatingSystem.SuggestedScsiDeviceType; } hd.Create (handler); } string diskFile = disk.FileName; if (diskFile != null && diskFile != "auto detect" && Path.IsPathRooted (diskFile) && Path.GetDirectoryName (diskFile) == Path.GetDirectoryName (file)) { diskFile = Path.GetFileName (diskFile); } string basekey = GetDiskBaseKey (disk); dict[basekey + "present"] = "TRUE"; dict[basekey + "fileName"] = diskFile; string disktype; if (disk is VirtualHardDisk) { disktype = "disk"; } else { CdDeviceType cdtype = (disk as VirtualCdDrive).CdDeviceType; if (OperatingSystem.IsLegacy && cdtype == CdDeviceType.Raw) { cdtype = CdDeviceType.Legacy; } disktype = Utility.CdDeviceTypeToString (cdtype); } dict[basekey + "deviceType"] = disktype; }
private string GetDiskBaseKey(VirtualDisk disk) { return GetDiskBaseKey (disk.BusType, disk.BusNumber, disk.DeviceNumber); }
private void RemoveDiskValues(VirtualDisk disk) { string basekey = GetDiskBaseKey (disk); foreach (string key in new List<string> (dict.Keys)) { if (key.StartsWith (basekey)) { dict.Remove (key); } } }
private void CheckConflictingDisk(VirtualDisk disk, List<int> list) { int hash = String.Format ("{0}{1}{2}", disk.BusNumber, disk.DeviceNumber, disk.BusType).GetHashCode (); if (list.Contains (hash)) { throw new ApplicationException (Catalog.GetString ("There are two conflicting disks. Please change the position of one of the disks and try again.")); } list.Add (hash); }