Exemplo n.º 1
0
        /// <summary>
        /// Create a new differencing disk, possibly within an existing disk.
        /// </summary>
        /// <param name="fileSystem">The file system to create the disk on</param>
        /// <param name="path">The path (or URI) for the disk to create</param>
        /// <returns>The newly created disk</returns>
        public override VirtualDisk CreateDifferencingDisk(DiscFileSystem fileSystem, string path)
        {
            FileLocator   locator = new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path));
            DiskImageFile file    = _files[0].First.CreateDifferencing(locator, Utilities.GetFileFromPath(path));

            return(new Disk(file, Ownership.Dispose));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the Disk class.
 /// </summary>
 /// <param name="fileSystem">The file system containing the disk.</param>
 /// <param name="path">The file system relative path to the disk.</param>
 /// <param name="access">The access requested to the disk.</param>
 public Disk(DiscFileSystem fileSystem, string path, FileAccess access)
 {
     _path = path;
     FileLocator fileLocator = new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path));
     _files = new List<ThinkAway.Tuple<VirtualDiskLayer, Ownership>>();
     _files.Add(new ThinkAway.Tuple<VirtualDiskLayer, Ownership>(new DiskImageFile(fileLocator, Utilities.GetFileFromPath(path), access), Ownership.Dispose));
     ResolveFileChain();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the Disk class.
        /// </summary>
        /// <param name="fileSystem">The file system containing the disk.</param>
        /// <param name="path">The file system relative path to the disk.</param>
        /// <param name="access">The access requested to the disk.</param>
        public Disk(DiscFileSystem fileSystem, string path, FileAccess access)
        {
            _path = path;
            FileLocator fileLocator = new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path));

            _files = new List <ThinkAway.Tuple <VirtualDiskLayer, Ownership> >();
            _files.Add(new ThinkAway.Tuple <VirtualDiskLayer, Ownership>(new DiskImageFile(fileLocator, Utilities.GetFileFromPath(path), access), Ownership.Dispose));
            ResolveFileChain();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the Disk class.  Differencing disks are supported.
        /// </summary>
        /// <param name="fileSystem">The file system containing the disk.</param>
        /// <param name="path">The file system relative path to the disk.</param>
        /// <param name="access">The access requested to the disk.</param>
        public Disk(DiscFileSystem fileSystem, string path, FileAccess access)
        {
            FileLocator   fileLocator = new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path));
            DiskImageFile file        = new DiskImageFile(fileLocator, Utilities.GetFileFromPath(path), access);

            _files = new List <AlIO.Tuple <DiskImageFile, Ownership> >();
            _files.Add(new AlIO.Tuple <DiskImageFile, Ownership>(file, Ownership.Dispose));
            ResolveFileChain();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new instance from a file on a file system.
        /// </summary>
        /// <param name="fileSystem">The file system containing the disk.</param>
        /// <param name="path">The file system relative path to the disk.</param>
        /// <param name="access">The access requested to the disk.</param>
        public Disk(DiscFileSystem fileSystem, string path, FileAccess access)
        {
            _path = path;
            FileLocator fileLocator = new DiscFileLocator(fileSystem, Path.GetDirectoryName(path));

            _files = new List <Tuple <DiskImageFile, Ownership> >();
            _files.Add(new Tuple <DiskImageFile, Ownership>(new DiskImageFile(fileLocator, Path.GetFileName(path), access), Ownership.Dispose));
            ResolveFileChain();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new virtual disk that is a linked clone of an existing disk.
        /// </summary>
        /// <param name="fileSystem">The file system to create the VMDK on</param>
        /// <param name="path">The path to the new disk</param>
        /// <param name="type">The type of the new disk</param>
        /// <param name="parent">The disk to clone</param>
        /// <returns>The new virtual disk</returns>
        public static DiskImageFile InitializeDifferencing(DiscFileSystem fileSystem, string path, DiskCreateType type, string parent)
        {
            if (type != DiskCreateType.MonolithicSparse && type != DiskCreateType.TwoGbMaxExtentSparse && type != DiskCreateType.VmfsSparse)
            {
                throw new ArgumentException("Differencing disks must be sparse", "type");
            }

            string      basePath      = Path.GetDirectoryName(path);
            FileLocator locator       = new DiscFileLocator(fileSystem, basePath);
            FileLocator parentLocator = locator.GetRelativeLocator(Path.GetDirectoryName(parent));

            using (DiskImageFile parentFile = new DiskImageFile(parentLocator, Path.GetFileName(parent), FileAccess.Read))
            {
                DescriptorFile baseDescriptor = CreateDifferencingDiskDescriptor(type, parentFile, parent);

                return(DoInitialize(locator, Path.GetFileName(path), parentFile.Capacity, type, baseDescriptor));
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the Disk class.  Differencing disks are supported.
 /// </summary>
 /// <param name="fileSystem">The file system containing the disk.</param>
 /// <param name="path">The file system relative path to the disk.</param>
 /// <param name="access">The access requested to the disk.</param>
 public Disk(DiscFileSystem fileSystem, string path, FileAccess access)
 {
     FileLocator fileLocator = new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path));
     DiskImageFile file = new DiskImageFile(fileLocator, Utilities.GetFileFromPath(path), access);
     _files = new List<DiscUtils.Tuple<DiskImageFile, Ownership>>();
     _files.Add(new DiscUtils.Tuple<DiskImageFile, Ownership>(file, Ownership.Dispose));
     ResolveFileChain();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Create a new differencing disk, possibly within an existing disk.
 /// </summary>
 /// <param name="fileSystem">The file system to create the disk on</param>
 /// <param name="path">The path (or URI) for the disk to create</param>
 /// <returns>The newly created disk</returns>
 public override VirtualDisk CreateDifferencingDisk(DiscFileSystem fileSystem, string path)
 {
     FileLocator locator = new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path));
     DiskImageFile file = _files[0].First.CreateDifferencing(locator, Utilities.GetFileFromPath(path));
     return new Disk(file, Ownership.Dispose);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a new virtual disk that is a linked clone of an existing disk.
        /// </summary>
        /// <param name="fileSystem">The file system to create the VMDK on</param>
        /// <param name="path">The path to the new disk</param>
        /// <param name="type">The type of the new disk</param>
        /// <param name="parent">The disk to clone</param>
        /// <returns>The new virtual disk</returns>
        public static DiskImageFile InitializeDifferencing(DiscFileSystem fileSystem, string path, DiskCreateType type, string parent)
        {
            if (type != DiskCreateType.MonolithicSparse && type != DiskCreateType.TwoGbMaxExtentSparse && type != DiskCreateType.VmfsSparse)
            {
                throw new ArgumentException("Differencing disks must be sparse", "type");
            }

            string basePath = Path.GetDirectoryName(path);
            FileLocator locator = new DiscFileLocator(fileSystem, basePath);
            FileLocator parentLocator = locator.GetRelativeLocator(Path.GetDirectoryName(parent));

            using (DiskImageFile parentFile = new DiskImageFile(parentLocator, Path.GetFileName(parent), FileAccess.Read))
            {
                DescriptorFile baseDescriptor = CreateDifferencingDiskDescriptor(type, parentFile, parent);

                return DoInitialize(locator, Path.GetFileName(path), parentFile.Capacity, type, baseDescriptor);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a new virtual disk at the specified path.
 /// </summary>
 /// <param name="fileSystem">The file system to create the disk on.</param>
 /// <param name="path">The name of the VMDK to create.</param>
 /// <param name="parameters">The desired parameters for the new disk.</param>
 /// <returns>The newly created disk image</returns>
 public static DiskImageFile Initialize(DiscFileSystem fileSystem, string path, DiskParameters parameters)
 {
     FileLocator locator = new DiscFileLocator(fileSystem, Path.GetDirectoryName(path));
     return Initialize(locator, Path.GetFileName(path), parameters);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Creates a new virtual disk at the specified path.
 /// </summary>
 /// <param name="fileSystem">The file system to create the disk on.</param>
 /// <param name="path">The name of the VMDK to create.</param>
 /// <param name="parameters">The desired parameters for the new disk.</param>
 /// <returns>The newly created disk image</returns>
 public static DiskImageFile Initialize(DiscFileSystem fileSystem, string path, DiskParameters parameters)
 {
     FileLocator locator = new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path));
     return Initialize(locator, Utilities.GetFileFromPath(path), parameters);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Creates a new virtual disk at the specified path.
        /// </summary>
        /// <param name="fileSystem">The file system to create the disk on.</param>
        /// <param name="path">The name of the VMDK to create.</param>
        /// <param name="parameters">The desired parameters for the new disk.</param>
        /// <returns>The newly created disk image</returns>
        public static DiskImageFile Initialize(DiscFileSystem fileSystem, string path, DiskParameters parameters)
        {
            FileLocator locator = new DiscFileLocator(fileSystem, Path.GetDirectoryName(path));

            return(Initialize(locator, Path.GetFileName(path), parameters));
        }
Exemplo n.º 13
0
 /// <summary>
 /// Creates a new instance from a file on a file system.
 /// </summary>
 /// <param name="fileSystem">The file system containing the disk.</param>
 /// <param name="path">The file system relative path to the disk.</param>
 /// <param name="access">The access requested to the disk.</param>
 public Disk(DiscFileSystem fileSystem, string path, FileAccess access)
 {
     FileLocator fileLocator = new DiscFileLocator(fileSystem, Path.GetDirectoryName(path));
     DiskImageFile file = new DiskImageFile(fileLocator, Path.GetFileName(path), access);
     _files = new List<Tuple<DiskImageFile, Ownership>>();
     _files.Add(new Tuple<DiskImageFile, Ownership>(file, Ownership.Dispose));
     ResolveFileChain();
 }