internal DiscFileSystemInfo(DiscFileSystem fileSystem, string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            _fileSystem = fileSystem;
            _path = path.Trim('\\');
        }
Exemplo n.º 2
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 abstract VirtualDisk CreateDifferencingDisk(DiscFileSystem fileSystem, string path);
Exemplo n.º 3
0
        /// <summary>
        /// Opens an existing virtual disk, possibly from within an existing disk.
        /// </summary>
        /// <param name="fs">The file system to open the disk on</param>
        /// <param name="path">The path of the virtual disk to open</param>
        /// <param name="access">The desired access to the disk</param>
        /// <returns>The Virtual Disk, or <c>null</c> if an unknown disk format</returns>
        public static VirtualDisk OpenDisk(DiscFileSystem fs, string path, FileAccess access)
        {
            if (fs == null)
            {
                return OpenDisk(path, access);
            }

            string extension = Path.GetExtension(path).ToUpperInvariant();
            if (extension.StartsWith(".", StringComparison.Ordinal))
            {
                extension = extension.Substring(1);
            }

            VirtualDiskFactory factory;
            if (ExtensionMap.TryGetValue(extension, out factory))
            {
                return factory.OpenDisk(fs, path, access);
            }

            return null;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a new virtual disk, possibly within an existing disk.
        /// </summary>
        /// <param name="fileSystem">The file system to create the disk on</param>
        /// <param name="type">The type of disk to create (see <see cref="SupportedDiskTypes"/>)</param>
        /// <param name="variant">The variant of the type to create (see <see cref="GetSupportedDiskVariants"/>)</param>
        /// <param name="path">The path (or URI) for the disk to create</param>
        /// <param name="capacity">The capacity of the new disk</param>
        /// <param name="geometry">The geometry of the new disk (or null).</param>
        /// <param name="parameters">Untyped parameters controlling the creation process (TBD)</param>
        /// <returns>The newly created disk</returns>
        public static VirtualDisk CreateDisk(DiscFileSystem fileSystem, string type, string variant, string path, long capacity, Geometry geometry, Dictionary<string, string> parameters)
        {
            VirtualDiskFactory factory = TypeMap[type];

            VirtualDiskParameters diskParams = new VirtualDiskParameters()
            {
                AdapterType = GenericDiskAdapterType.Scsi,
                Capacity = capacity,
                Geometry = geometry,
            };

            if (parameters != null)
            {
                foreach (var key in parameters.Keys)
                {
                    diskParams.ExtendedParameters[key] = parameters[key];
                }
            }

            return factory.CreateDisk(new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path)), variant.ToLowerInvariant(), Utilities.GetFileFromPath(path), diskParams);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Indicates if <paramref name="obj"/> is equivalent to this object.
        /// </summary>
        /// <param name="obj">The object to compare</param>
        /// <returns><c>true</c> if <paramref name="obj"/> is equivalent, else <c>false</c></returns>
        public override bool Equals(object obj)
        {
            DiscFileSystemInfo asInfo = obj as DiscFileSystemInfo;

            if (obj == null)
            {
                return(false);
            }

            return(string.Compare(Path, asInfo.Path, StringComparison.Ordinal) == 0 && DiscFileSystem.Equals(FileSystem, asInfo.FileSystem));
        }
 public VirtualDisk OpenDisk(DiscFileSystem fileSystem, string path, FileAccess access)
 {
     return OpenDisk(new DiscFileLocator(fileSystem, @"\"), path, access);
 }
Exemplo n.º 7
0
 public DiscFileLocator(DiscFileSystem fileSystem, string basePath)
 {
     _fileSystem = fileSystem;
     _basePath = basePath;
 }
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 abstract VirtualDisk CreateDifferencingDisk(DiscFileSystem fileSystem, string path);
Exemplo n.º 9
0
 internal DiscFileInfo(DiscFileSystem fileSystem, string path)
     : base(fileSystem, path)
 {
 }
Exemplo n.º 10
0
 internal DiscFileInfo(DiscFileSystem fileSystem, string path)
     : base(fileSystem, path)
 {
 }
Exemplo n.º 11
0
 public DiscFileLocator(DiscFileSystem fileSystem, string basePath)
 {
     _fileSystem = fileSystem;
     _basePath   = basePath;
 }
Exemplo n.º 12
0
 public VirtualDisk OpenDisk(DiscFileSystem fileSystem, string path, FileAccess access)
 {
     return(OpenDisk(new DiscFileLocator(fileSystem, @"\"), path, access));
 }