private void ResolveFileChain() { VirtualDiskLayer file = _files[_files.Count - 1].First; while (file.NeedsParent) { bool foundParent = false; FileLocator locator = file.RelativeFileLocator; foreach (string posParent in file.GetParentLocations()) { if (locator.Exists(posParent)) { file = VirtualDisk.OpenDiskLayer(file.RelativeFileLocator, posParent, FileAccess.Read); _files.Add(new ThinkAway.Tuple <VirtualDiskLayer, Ownership>(file, Ownership.Dispose)); foundParent = true; break; } } if (!foundParent) { throw new IOException("Parent disk not found"); } } }
private void ResolveFileChain() { DiskImageFile file = _files[_files.Count - 1].First; while (file.NeedsParent) { FileLocator fileLocator = file.RelativeFileLocator; bool found = false; foreach (string testPath in file.GetParentLocations()) { if (fileLocator.Exists(testPath)) { DiskImageFile newFile = new DiskImageFile(fileLocator, testPath, FileAccess.Read); if (newFile.UniqueId != file.ParentUniqueId) { throw new IOException(string.Format(CultureInfo.InstalledUICulture, "Invalid disk chain found looking for parent with id {0}, found {1} with id {2}", file.ParentUniqueId, newFile.FullPath, newFile.UniqueId)); } file = newFile; _files.Add(new AlIO.Tuple <DiskImageFile, Ownership>(file, Ownership.Dispose)); found = true; break; } } if (!found) { throw new IOException(string.Format(CultureInfo.InvariantCulture, "Failed to find parent for disk '{0}'", file.FullPath)); } } }