예제 #1
0
 private LocaleFileInfo GetLocaleFile(string FullFileName)
 {
     foreach (LocaleFileInfo LocaleFile in List)
     {
         if (LocaleFileUtil.GetFullFileName(LocaleFile).Replace("\\", "/") == FullFileName.Replace("\\", "/"))
         {
             return(LocaleFile);
         }
     }
     return(null);
 }
예제 #2
0
        private string CreateResourcePack(LocaleFilePack ResourcePack, string FileName, LanguagePackType packtype)
        {
            int    CompressionLevel = 9;
            int    BlockSize        = 4096;
            string ResPackName;
            string ResPackShortName;

            ResPackShortName = "ResourcePack." + FileName + ".";
            if (packtype == LanguagePackType.Core || packtype == LanguagePackType.Full)
            {
                ResPackShortName += Globals.glbAppVersion + ".";
            }
            ResPackShortName += ResourcePack.LocalePackCulture.Code + ".zip";
            ResPackName       = Globals.HostMapPath + ResPackShortName;

            FileStream strmZipFile = null;

            try
            {
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.CreateArchive"), ResPackShortName));
                strmZipFile = File.Create(ResPackName);
                ZipOutputStream strmZipStream = null;
                try
                {
                    strmZipStream = new ZipOutputStream(strmZipFile);

                    ZipEntry myZipEntry;
                    myZipEntry = new ZipEntry("Manifest.xml");

                    strmZipStream.PutNextEntry(myZipEntry);
                    strmZipStream.SetLevel(CompressionLevel);

                    byte[] FileData = GetLanguagePackManifest(ResourcePack);

                    strmZipStream.Write(FileData, 0, FileData.Length);
                    ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.SavedFile"), "Manifest.xml"));

                    foreach (LocaleFileInfo LocaleFile in ResourcePack.Files)
                    {
                        myZipEntry = new ZipEntry(LocaleFileUtil.GetFullFileName(LocaleFile));
                        strmZipStream.PutNextEntry(myZipEntry);
                        strmZipStream.Write(LocaleFile.Buffer, 0, LocaleFile.Buffer.Length);
                        ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.SavedFile"), LocaleFile.LocaleFileName));
                    }
                }
                catch (Exception ex)
                {
                    Exceptions.Exceptions.LogException(ex);
                    ProgressLog.AddFailure(string.Format(Localization.GetString("LOG.LangPack.ERROR.SavingFile"), ex));
                }
                finally
                {
                    if (strmZipStream != null)
                    {
                        strmZipStream.Finish();
                        strmZipStream.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                ProgressLog.AddFailure(string.Format(Localization.GetString("LOG.LangPack.ERROR.SavingFile"), ex));
            }
            finally
            {
                if (strmZipFile != null)
                {
                    strmZipFile.Close();
                }
            }

            return(ResPackName);
        }