예제 #1
0
        private void UncompressLinkedFiles(Dictionary <String, DateTime> fileList, String destinationLinkedFilesPath,
                                           String linkedFilesPathPersisted)
        {
            using (var zipIn = OpenFWBackupZipfile())
            {
                ZipEntry entry;

                while ((entry = zipIn.GetNextEntry()) != null)
                {
                    //Code to use for restoring files with new file structure.
                    if (fileList.ContainsKey(entry.Name))
                    {
                        var fileName = Path.GetFileName(entry.Name);
                        Debug.Assert(!String.IsNullOrEmpty(fileName));

                        //Contruct the path where the file will be unzipped too.
                        var    zipFileLinkFilesPath    = DirectoryFinder.GetZipfileFormatedPath(linkedFilesPathPersisted);
                        var    filenameWithSubFolders  = entry.Name.Substring(zipFileLinkFilesPath.Length);
                        var    pathForFileSubFolders   = filenameWithSubFolders.Substring(1, filenameWithSubFolders.Length - fileName.Length - 1);
                        var    destFolderZipFileFormat = DirectoryFinder.GetZipfileFormatedPath(destinationLinkedFilesPath);
                        string pathRoot = Path.GetPathRoot(destinationLinkedFilesPath);
                        Debug.Assert(!String.IsNullOrEmpty(pathRoot));
                        var pathforfileunzip = Path.Combine(pathRoot, Path.Combine(destFolderZipFileFormat, pathForFileSubFolders));
                        UnzipFileToRestoreFolder(zipIn, fileName, entry.Size, pathforfileunzip, entry.DateTime);
                    }
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Verifies the file exists in the zip file.
        /// </summary>
        /// <param name="zip">The zip file.</param>
        /// <param name="fileNameAndPath">The file name (with path) to look for.</param>
        /// ------------------------------------------------------------------------------------
        private static void VerifyFileExistsInZipFile(ZipFile zip, String fileNameAndPath)
        {
            string str = DirectoryFinder.GetZipfileFormatedPath(fileNameAndPath);
            //ensure the entry is the correct one.
            ZipEntry entry = zip.GetEntry(str);

            Assert.True(entry.Name.Equals(str), String.Format("File {0} should exist in zipFile", str));
        }
예제 #3
0
        private void RestoreFrom7_0AndNewerBackup(BackupFileSettings fileSettings)
        {
            // Get rid of any saved settings, since they may not be consistent with something about the data
            // or settings we are restoring. (This extension is also known to RecordView.GetClerkPersistPathname()).
            var tempDirectory = Path.Combine(m_restoreSettings.ProjectPath, DirectoryFinder.ksSortSequenceTempDir);

            if (Directory.Exists(tempDirectory))
            {
                foreach (var sortSeqFile in Directory.GetFiles(tempDirectory, "*.fwss"))
                {
                    File.Delete(sortSeqFile);
                }
            }

            UncompressDataFile();

            // We can't use Path.Combine here, because the zip files stores all file paths with '/'s
            UncompressFilesMatchingPath(DirectoryFinder.ksWritingSystemsDir + "/", m_restoreSettings.WritingSystemStorePath);

            if (m_restoreSettings.IncludeSupportingFiles)
            {
                Debug.Assert(fileSettings.IncludeSupportingFiles,
                             "The option to include supporting files should not be allowed if they aren't available in the backup settings");
                var zipEntryStartsWith = DirectoryFinder.ksSupportingFilesDir;
                UncompressFilesContainedInFolderandSubFolders(DirectoryFinder.GetZipfileFormatedPath(zipEntryStartsWith),
                                                              m_restoreSettings.ProjectSupportingFilesPath);
            }

            if (m_restoreSettings.IncludeConfigurationSettings)
            {
                UncompressFilesMatchingPath(DirectoryFinder.ksConfigurationSettingsDir + "/", m_restoreSettings.FlexConfigurationSettingsPath);
            }

            if (m_restoreSettings.IncludeLinkedFiles)
            {
                RestoreLinkedFiles(fileSettings);
            }

            if (m_restoreSettings.IncludeSpellCheckAdditions)
            {
                UncompressFilesMatchingPath(BackupSettings.ksSpellingDictionariesDir + "/", m_restoreSettings.SpellingDictionariesPath);

                CopySpellingOverrideFilesFromBackupToEnchant();
            }
        }
예제 #4
0
        private Dictionary <String, DateTime> GetAllFilesUnderFolderInZipFileAndDateTimes(string dir)
        {
            var filesAndDateTime = new Dictionary <String, DateTime>();
            var dirZipFileFormat = DirectoryFinder.GetZipfileFormatedPath(dir);

            using (var zipIn = OpenFWBackupZipfile())
            {
                ZipEntry entry;

                while ((entry = zipIn.GetNextEntry()) != null)
                {
                    var fileName = Path.GetFileName(entry.Name);

                    //Code to use for restoring files with new file structure.
                    if (!String.IsNullOrEmpty(fileName) && !entry.Name.EndsWith("/") && entry.Name.StartsWith(dirZipFileFormat))
                    {
                        filesAndDateTime.Add(entry.Name, entry.DateTime);
                    }
                }
                return(filesAndDateTime);
            }
        }