123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- using Utilities;
- namespace DiskAccessLibrary
- {
- public abstract partial class DiskImage : Disk
- {
- private string m_path;
- public DiskImage(string diskImagePath)
- {
- m_path = diskImagePath;
- }
- public void CheckBoundaries(long sectorIndex, int sectorCount)
- {
- if (sectorIndex < 0 || sectorIndex + (sectorCount - 1) >= this.TotalSectors)
- {
- throw new ArgumentOutOfRangeException("Attempted to access data outside of disk");
- }
- }
- public abstract void Extend(long numberOfAdditionalBytes);
- public abstract bool ExclusiveLock();
- public abstract bool ReleaseLock();
- public string Path
- {
- get
- {
- return m_path;
- }
- }
-
-
-
-
- public static DiskImage GetDiskImage(string path)
- {
- if (path.EndsWith(".vhd", StringComparison.InvariantCultureIgnoreCase))
- {
- return new VirtualHardDisk(path);
- }
- else if (path.EndsWith(".vmdk", StringComparison.InvariantCultureIgnoreCase))
- {
- return new VirtualMachineDisk(path);
- }
- else
- {
- return new RawDiskImage(path);
- }
- }
- }
- }
|