コード例 #1
0
        private void ParseDescriptor(List <string> lines)
        {
            ExtentEntries = new List <VirtualMachineDiskExtentEntry>();

            foreach (string line in lines)
            {
                if (line.StartsWith("version", StringComparison.OrdinalIgnoreCase))
                {
                    string value = line.Substring(line.IndexOf('=') + 1).Trim();
                    Version = Conversion.ToInt32(value);
                }
                else if (line.StartsWith("CID", StringComparison.OrdinalIgnoreCase))
                {
                    string value = line.Substring(line.IndexOf('=') + 1).Trim();
                    ContentID = UInt32.Parse(value, System.Globalization.NumberStyles.HexNumber);
                }
                else if (line.StartsWith("ParentCID", StringComparison.OrdinalIgnoreCase))
                {
                    string value = line.Substring(line.IndexOf('=') + 1).Trim();
                    ParentContentID = UInt32.Parse(value, System.Globalization.NumberStyles.HexNumber);
                }
                else if (line.StartsWith("createType", StringComparison.OrdinalIgnoreCase))
                {
                    string value = line.Substring(line.IndexOf('=') + 1).Trim();
                    value    = QuotedStringUtils.Unquote(value);
                    DiskType = GetFromString(value);
                }
                else if (line.StartsWith("RW", StringComparison.OrdinalIgnoreCase) ||
                         line.StartsWith("RDONLY", StringComparison.OrdinalIgnoreCase) ||
                         line.StartsWith("NOACCESS", StringComparison.OrdinalIgnoreCase))
                {
                    VirtualMachineDiskExtentEntry entry = VirtualMachineDiskExtentEntry.ParseEntry(line);
                    ExtentEntries.Add(entry);
                }
                else if (line.StartsWith("ddb.adapterType", StringComparison.OrdinalIgnoreCase))
                {
                    string value = line.Substring(line.IndexOf('=') + 1).Trim();
                    value   = QuotedStringUtils.Unquote(value);
                    Adapter = value;
                }
                else if (line.StartsWith("ddb.geometry.sectors", StringComparison.OrdinalIgnoreCase))
                {
                    string value = line.Substring(line.IndexOf('=') + 1).Trim();
                    value           = QuotedStringUtils.Unquote(value);
                    SectorsPerTrack = Conversion.ToInt32(value);
                }
                else if (line.StartsWith("ddb.geometry.heads", StringComparison.OrdinalIgnoreCase))
                {
                    string value = line.Substring(line.IndexOf('=') + 1).Trim();
                    value             = QuotedStringUtils.Unquote(value);
                    TracksPerCylinder = Conversion.ToInt32(value);
                }
                else if (line.StartsWith("ddb.geometry.cylinders", StringComparison.OrdinalIgnoreCase))
                {
                    string value = line.Substring(line.IndexOf('=') + 1).Trim();
                    value     = QuotedStringUtils.Unquote(value);
                    Cylinders = Conversion.ToInt64(value);
                }
            }
        }
コード例 #2
0
        public static VirtualMachineDiskExtentEntry ParseEntry(string line)
        {
            VirtualMachineDiskExtentEntry entry = new VirtualMachineDiskExtentEntry();
            List <string> parts = QuotedStringUtils.SplitIgnoreQuotedSeparators(line, ' ');

            if (String.Equals(parts[0], "RW", StringComparison.InvariantCultureIgnoreCase))
            {
                entry.WriteAccess = true;
                entry.ReadAccess  = true;
            }
            else if (String.Equals(parts[0], "RDONLY", StringComparison.InvariantCultureIgnoreCase))
            {
                entry.ReadAccess = true;
            }
            entry.SizeInSectors = Conversion.ToInt64(parts[1]);
            entry.ExtentType    = GetExtentTypeFromString(parts[2]);
            entry.FileName      = QuotedStringUtils.Unquote(parts[3]);
            if (parts.Count > 4)
            {
                entry.Offset = Conversion.ToInt64(parts[4]);
            }
            return(entry);
        }