Пример #1
0
        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 ThinkAway.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));
                }
            }
        }