상속: IDisposable
예제 #1
0
        private static IList<VhdValidationResult> DoValidate(VhdValidationType validation, VhdFile vhdFile, Exception exception)
        {
            var result = new List<VhdValidationResult>();

            if ((validation & VhdValidationType.IsVhd) == VhdValidationType.IsVhd)
            {
                var validationResult = new VhdValidationResult
                                           {
                                               ValidationType = VhdValidationType.IsVhd
                                           };
                if (vhdFile == null)
                {
                    validationResult.ErrorCode = 1000;
                    validationResult.Error = exception;
                }
                result.Add(validationResult);
            }

            if ((validation & VhdValidationType.FixedDisk) == VhdValidationType.FixedDisk)
            {
                var validationResult = new VhdValidationResult
                                           {
                                               ValidationType = VhdValidationType.FixedDisk
                                           };
                if (vhdFile == null || vhdFile.Footer.DiskType != DiskType.Fixed)
                {
                    validationResult.ErrorCode = 1001;
                }
                result.Add(validationResult);
            }
            return result;
        }
 public VirtualDiskStream(string vhdPath)
 {
     this.vhdFile = new VhdFileFactory().Create(vhdPath);
     this.blockFactory = vhdFile.GetBlockFactory();
     footerRange = this.blockFactory.GetFooterRange();
     fileDataRange = IndexRange.FromLength(0, this.Length - footerRange.Length);
 }
예제 #3
0
 public VhdFile(VhdFooter footer, VhdHeader header, BlockAllocationTable bat, VhdFile parent, Stream stream)
 {
     this.Footer = footer;
     this.Header = header;
     this.BlockAllocationTable = bat;
     this.Parent = parent;
     this.reader = new BinaryReader(stream, Encoding.Unicode);
     DataReader = new VhdDataReader(this.reader);
 }
예제 #4
0
 public VhdFile(VhdFooter footer, VhdHeader header, BlockAllocationTable bat, VhdFile parent, Stream stream)
 {
     this.Footer = footer;
     this.Header = header;
     this.BlockAllocationTable = bat;
     this.Parent = parent;
     this.reader = new BinaryReader(stream, Encoding.Unicode);
     DataReader  = new VhdDataReader(this.reader);
 }
예제 #5
0
        public static IList <VhdValidationResult> Validate(VhdValidationType validation, Stream vhdStream)
        {
            var       fileFactory = new VhdFileFactory();
            VhdFile   vhdFile     = null;
            Exception exception   = null;

            try
            {
                vhdFile = fileFactory.Create(vhdStream);
            }
            catch (VhdParsingException e)
            {
                exception = e;
            }

            return(DoValidate(validation, vhdFile, exception));
        }
예제 #6
0
        private static IEnumerable <CompletionPort> ValidateAsync(AsyncMachine <IList <VhdValidationResult> > machine, VhdValidationType validation, Stream vhdStream)
        {
            var result = new List <VhdValidationResult>();

            var fileFactory = new VhdFileFactory();

            fileFactory.BeginCreate(vhdStream, machine.CompletionCallback, null);
            yield return(CompletionPort.SingleOperation);

            VhdFile   vhdFile   = null;
            Exception exception = null;

            try
            {
                vhdFile = fileFactory.EndCreate(machine.CompletionResult);
            }
            catch (VhdParsingException e)
            {
                exception = e;
            }

            machine.ParameterValue = DoValidate(validation, vhdFile, exception);
        }
예제 #7
0
        private static IList <VhdValidationResult> DoValidate(VhdValidationType validation, VhdFile vhdFile, Exception exception)
        {
            var result = new List <VhdValidationResult>();

            if ((validation & VhdValidationType.IsVhd) == VhdValidationType.IsVhd)
            {
                var validationResult = new VhdValidationResult
                {
                    ValidationType = VhdValidationType.IsVhd
                };
                if (vhdFile == null)
                {
                    validationResult.ErrorCode = 1000;
                    validationResult.Error     = exception;
                }
                result.Add(validationResult);
            }

            if ((validation & VhdValidationType.FixedDisk) == VhdValidationType.FixedDisk)
            {
                var validationResult = new VhdValidationResult
                {
                    ValidationType = VhdValidationType.FixedDisk
                };
                if (vhdFile == null || vhdFile.Footer.DiskType != DiskType.Fixed)
                {
                    validationResult.ErrorCode = 1001;
                }
                result.Add(validationResult);
            }
            return(result);
        }