public static VhdFilePath GetFilePathBy(this VhdFile vhdFile, Guid uniqueId) { VhdFilePath result = null; string baseVhdPath = String.Empty; var newBlocksOwners = new List <Guid> { Guid.Empty }; var current = vhdFile; while (current != null && current.Footer.UniqueId != uniqueId) { newBlocksOwners.Add(current.Footer.UniqueId); if (current.Parent != null) { result = new VhdFilePath(current.Header.GetAbsoluteParentPath(), current.Header.GetRelativeParentPath()); } current = current.Parent; } if (result == null) { string message = String.Format("There is no parent VHD file with with the id '{0}'", uniqueId); throw new InvalidOperationException(message); } return(result); }
private FileMetaData GetFileMetaData(CloudPageBlob baseBlob, VhdFilePath localBaseVhdPath) { FileMetaData fileMetaData; if (File.Exists(localBaseVhdPath.AbsolutePath)) { fileMetaData = FileMetaData.Create(localBaseVhdPath.AbsolutePath); } else { var filePath = Path.Combine(localVhd.Directory.FullName, localBaseVhdPath.RelativePath); if (File.Exists(filePath)) { fileMetaData = FileMetaData.Create(filePath); } else { var message = String.Format("Cannot find the local base image for '{0}' in neither of the locations '{1}', '{2}'.", baseBlob.Uri, localBaseVhdPath.AbsolutePath, localBaseVhdPath.RelativePath); throw new InvalidOperationException(message); } } return(fileMetaData); }