entries() public method

public entries ( ) : global::java.util.Enumeration
return global::java.util.Enumeration
Exemplo n.º 1
1
        public void UnZip(string zipFileLocation, string destinationRootFolder, string zipRootToRemove)
        {
            try
            {
                var zipFile = new ZipFile(zipFileLocation);
                var zipFileEntries = zipFile.entries();
                
                while (zipFileEntries.hasMoreElements())
                {
                    var zipEntry = (ZipEntry)zipFileEntries.nextElement();

                    var name = zipEntry.getName().Replace(zipRootToRemove, "").Replace("/", "\\").TrimStart('/').TrimStart('\\');
                    var p = this.fileSystem.Path.Combine(destinationRootFolder, name);

                    if (zipEntry.isDirectory())
                    {
                        if (!this.fileSystem.Directory.Exists(p))
                        {
                            this.fileSystem.Directory.CreateDirectory(p);
                        };
                    }
                    else
                    {
                        using (var bis = new BufferedInputStream(zipFile.getInputStream(zipEntry)))
                        {
                            var buffer = new byte[2048];
                            var count = buffer.GetLength(0);
                            using (var fos = new FileOutputStream(p))
                            {
                                using (var bos = new BufferedOutputStream(fos, count))
                                {
                                    int size;
                                    while ((size = bis.read(buffer, 0, count)) != -1)
                                    {
                                        bos.write(buffer, 0, size);
                                    }

                                    bos.flush();
                                    bos.close();
                                }
                            }

                            bis.close();
                        }
                    }
                }

                zipFile.close();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            catch (Exception e)
            {
                var t = e.ToString();
            }
        }
Exemplo n.º 2
0
    public static string[] getMetaInfEntryNames(object thisJarFile)
    {
#if FIRST_PASS
        return(null);
#else
        java.util.zip.ZipFile zf      = (java.util.zip.ZipFile)thisJarFile;
        java.util.Enumeration entries = zf.entries();
        List <string>         list    = null;
        while (entries.hasMoreElements())
        {
            java.util.zip.ZipEntry entry = (java.util.zip.ZipEntry)entries.nextElement();
            if (entry.getName().StartsWith("META-INF/", StringComparison.OrdinalIgnoreCase))
            {
                if (list == null)
                {
                    list = new List <string>();
                }
                list.Add(entry.getName());
            }
        }
        return(list == null ? null : list.ToArray());
#endif
    }
	public void m(ZipFile f) {
		Enumeration<ZipEntry> entries = f.entries();
	}
Exemplo n.º 4
0
 private List<ZipEntry> GetZipFiles(ZipFile zipfil)
 {
     List<ZipEntry> lstZip = new List<ZipEntry>();
     Enumeration zipEnum = zipfil.entries();
     while (zipEnum.hasMoreElements())
     {
         ZipEntry zip = (ZipEntry)zipEnum.nextElement();
         lstZip.Add(zip);
     }
     return lstZip;
 }
Exemplo n.º 5
0
 public bool FromLocalFile(string file, out IAdditionalContent content)
 {
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     try
     {
         string tempFileName;
         string str6;
         string str7;
         string extension = Path.GetExtension(file);
         XmlDocument document = null;
         switch (extension)
         {
             case ".scd":
             case ".zip":
             {
                 ZipFile file2 = null;
                 try
                 {
                     file2 = new ZipFile(file);
                     Enumeration enumeration = file2.entries();
                     List<ZipEntry> list = new List<ZipEntry>();
                     while (enumeration.hasMoreElements())
                     {
                         list.Add(enumeration.nextElement() as ZipEntry);
                     }
                     foreach (ZipEntry entry in list)
                     {
                         if (!entry.isDirectory())
                         {
                             this.NumberOfFiles++;
                         }
                         if (entry.getName().ToLower().EndsWith("mod_info.lua"))
                         {
                             string path = entry.getName();
                             string directoryName = Path.GetDirectoryName(path);
                             if ((directoryName == null) || (directoryName.Length < 1))
                             {
                                 directoryName = Path.GetDirectoryName(file);
                             }
                             this.mModName = new DirectoryInfo(directoryName).Name;
                             path = Path.GetFileName(path);
                             InputStream stream = null;
                             try
                             {
                                 stream = file2.getInputStream(entry);
                                 byte[] bytes = new byte[0x1000];
                                 bool flag = false;
                                 string contents = "";
                                 while (!flag)
                                 {
                                     int index = 0;
                                     while (index < bytes.Length)
                                     {
                                         int num = stream.read();
                                         if (num < 0)
                                         {
                                             flag = true;
                                             break;
                                         }
                                         bytes[index] = (byte) num;
                                         index++;
                                     }
                                     contents = contents + Encoding.UTF8.GetString(bytes, 0, index);
                                 }
                                 tempFileName = Path.GetTempFileName();
                                 System.IO.File.WriteAllText(tempFileName, contents);
                                 str7 = LuaUtil.ModToXml(tempFileName, out str6);
                                 if ((str6 != null) && (str6.Length > 0))
                                 {
                                     ErrorLog.WriteLine("Error parsing Mod file: {0}", new object[] { str6 });
                                     content = null;
                                     return false;
                                 }
                                 document = new XmlDocument();
                                 document.LoadXml(str7);
                                 base.LocalFilePath = file;
                                 System.IO.File.Delete(tempFileName);
                             }
                             finally
                             {
                                 if (stream != null)
                                 {
                                     stream.close();
                                 }
                             }
                         }
                     }
                 }
                 finally
                 {
                     file2.close();
                 }
                 break;
             }
             default:
                 if (extension == ".lua")
                 {
                     if (!file.EndsWith("mod_info.lua"))
                     {
                         content = null;
                         return false;
                     }
                     str7 = LuaUtil.ModToXml(file, out str6);
                     if ((str6 != null) && (str6.Length > 0))
                     {
                         ErrorLog.WriteLine("Error parsing Mod file: {0}", new object[] { str6 });
                         content = null;
                         return false;
                     }
                     document = new XmlDocument();
                     document.LoadXml(str7);
                     base.LocalFilePath = Path.GetDirectoryName(file);
                     this.mNumberOfFiles = Directory.GetFiles(base.LocalFilePath, "*.*", SearchOption.AllDirectories).Length;
                     this.mModName = new DirectoryInfo(Path.GetDirectoryName(file)).Name;
                 }
                 break;
         }
         if (document == null)
         {
             content = null;
             return false;
         }
         base.Name = document["mod"]["name"].InnerText;
         base.Description = document["mod"]["description"].InnerText;
         if (document["mod"]["copyright"] != null)
         {
             this.Copyright = document["mod"]["copyright"].InnerText.Replace("\x00a9", "").Replace("\x00ef\x00bf\x00bd", "");
         }
         if (document["mod"]["author"] != null)
         {
             this.DeveloperName = document["mod"]["author"].InnerText;
         }
         if (document["mod"]["url"] != null)
         {
             this.Website = document["mod"]["url"].InnerText;
         }
         this.Exclusive = this.ParseBool(document["mod"]["exclusive"].InnerText);
         this.UIOnly = new bool?(this.ParseBool(document["mod"]["ui_only"].InnerText));
         this.Guid = document["mod"]["uid"].InnerText;
         if (document["mod"]["requires"] != null)
         {
             this.mRequirements = document["mod"]["requires"].InnerText;
         }
         if (document["mod"]["requiresNames"] != null)
         {
             this.mRequirementNames = document["mod"]["requiresNames"].InnerText;
         }
         if (document["mod"]["conflicts"] != null)
         {
             this.mConflicts = document["mod"]["conflicts"].InnerText;
         }
         if (((document["mod"]["icon"] != null) && (document["mod"]["icon"].InnerText != null)) && (document["mod"]["icon"].InnerText.Length > 0))
         {
             string targetFile = document["mod"]["icon"].InnerText.Replace("/", @"\");
             if (extension == ".lua")
             {
                 if (targetFile.IndexOf(this.ModName) >= 0)
                 {
                     targetFile = targetFile.Remove(0, targetFile.IndexOf(this.ModName)).TrimStart(@"\".ToCharArray());
                 }
                 string str9 = Path.GetDirectoryName(base.LocalFilePath);
                 string str10 = targetFile;
                 string str11 = Path.Combine(str9, str10);
                 if (Path.GetExtension(str11) == ".dds")
                 {
                     this.mPreviewImage50 = ConvertDDS.ToBitmap(str11);
                 }
                 else
                 {
                     this.mPreviewImage50 = Image.FromFile(str11);
                 }
             }
             else
             {
                 tempFileName = Path.GetTempFileName();
                 Compression.Unzip(file, targetFile, tempFileName);
                 if (Path.GetExtension(targetFile) == ".dds")
                 {
                     this.mPreviewImage50 = ConvertDDS.ToBitmap(tempFileName);
                 }
                 else
                 {
                     this.mPreviewImage50 = Image.FromFile(tempFileName);
                 }
                 System.IO.File.Delete(tempFileName);
             }
             this.mHasPreview = true;
         }
         else
         {
             this.mPreviewImage50 = null;
         }
         content = this;
         return true;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         content = null;
         return false;
     }
 }
Exemplo n.º 6
0
 public bool FromLocalFile(string file, out IAdditionalContent content)
 {
     Exception exception;
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     try
     {
         byte[] buffer;
         int num2;
         string extension = Path.GetExtension(file);
         string contents = "";
         XmlDocument document = null;
         switch (extension)
         {
             case ".scd":
             case ".zip":
             {
                 ZipFile file2 = null;
                 try
                 {
                     file2 = new ZipFile(file);
                     Enumeration enumeration = file2.entries();
                     List<ZipEntry> list = new List<ZipEntry>();
                     while (enumeration.hasMoreElements())
                     {
                         list.Add(enumeration.nextElement() as ZipEntry);
                     }
                     bool flag = false;
                     foreach (ZipEntry entry in list)
                     {
                         if (entry.getName().EndsWith("_scenario.lua"))
                         {
                             string fileName = Path.GetFileName(entry.getName());
                             this.mMapName = fileName.Remove(fileName.IndexOf("_scenario.lua"), "_scenario.lua".Length);
                             InputStream stream = null;
                             try
                             {
                                 string str5;
                                 stream = file2.getInputStream(entry);
                                 buffer = new byte[0x1000];
                                 bool flag2 = false;
                                 while (!flag2)
                                 {
                                     num2 = 0;
                                     while (num2 < buffer.Length)
                                     {
                                         int num = stream.read();
                                         if (num < 0)
                                         {
                                             flag2 = true;
                                             break;
                                         }
                                         buffer[num2] = (byte) num;
                                         num2++;
                                     }
                                     contents = contents + Encoding.UTF8.GetString(buffer, 0, num2);
                                 }
                                 string tempFileName = Path.GetTempFileName();
                                 System.IO.File.WriteAllText(tempFileName, contents);
                                 if (!LuaUtil.VerifyScenario(tempFileName, out str5))
                                 {
                                     ErrorLog.WriteLine("Error loading custom map file {0}: {1}", new object[] { Path.GetFileName(tempFileName), str5 });
                                     content = null;
                                     return false;
                                 }
                                 new XmlDocument().LoadXml(LuaUtil.ScenarioToXml(tempFileName));
                                 System.IO.File.Delete(tempFileName);
                                 base.LocalFilePath = file;
                                 flag = true;
                                 break;
                             }
                             finally
                             {
                                 if (stream != null)
                                 {
                                     stream.close();
                                 }
                             }
                         }
                     }
                     if (!flag)
                     {
                         content = null;
                         return false;
                     }
                 }
                 finally
                 {
                     file2.close();
                 }
                 goto Label_03C3;
             }
             default:
             {
                 if (!(extension == ".lua"))
                 {
                     goto Label_03C3;
                 }
                 if (!file.EndsWith("_scenario.lua"))
                 {
                     content = null;
                     return false;
                 }
                 this.mMapName = Path.GetFileName(file);
                 this.mMapName = this.mMapName.Remove(this.mMapName.IndexOf("_scenario.lua"), "_scenario.lua".Length);
                 document = new XmlDocument();
                 document.LoadXml(LuaUtil.ScenarioToXml(file));
                 FileStream stream2 = null;
                 for (num2 = 0; num2 < 3; num2++)
                 {
                     try
                     {
                         bool flag4;
                         base.LocalFilePath = Path.GetDirectoryName(file);
                         stream2 = System.IO.File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
                         buffer = new byte[0x1000];
                         int count = 0;
                         goto Label_034E;
                     Label_0316:
                         count = stream2.Read(buffer, 0, buffer.Length);
                         if (count < 1)
                         {
                             break;
                         }
                         contents = contents + Encoding.UTF8.GetString(buffer, 0, count);
                     Label_034E:
                         flag4 = true;
                         goto Label_0316;
                     }
                     catch (Exception exception1)
                     {
                         exception = exception1;
                         ErrorLog.WriteLine(exception);
                         Thread.Sleep(0x3e8);
                     }
                     finally
                     {
                         if (stream2 != null)
                         {
                             stream2.Close();
                         }
                     }
                 }
                 break;
             }
         }
         if ((contents == null) || (contents.Length < 1))
         {
             content = null;
             return false;
         }
     Label_03C3:
         if (document == null)
         {
             content = null;
             return false;
         }
         base.Name = document["scenario"]["name"].InnerText;
         this.mMapDescription = document["scenario"]["description"].InnerText;
         this.mWidth = int.Parse(document["scenario"]["size"]["width"].InnerText);
         this.mHeight = int.Parse(document["scenario"]["size"]["height"].InnerText);
         this.mSize = (this.Width + this.Height) / 2;
         this.mMaxPlayers = int.Parse(document["scenario"]["max_players"].InnerText);
         string innerText = document["scenario"]["map"].InnerText;
         if ((extension == ".scd") || (extension == ".zip"))
         {
             this.mPreviewImage256 = ExtractZippedImage(file, innerText);
         }
         else
         {
             this.mPreviewImage256 = ExtractImage(file, innerText);
         }
         this.mPreviewImage50 = null;
         this.mPreviewImage128 = null;
         content = this;
         return true;
     }
     catch (Exception exception2)
     {
         exception = exception2;
         ErrorLog.WriteLine(exception);
         content = null;
         return false;
     }
 }
Exemplo n.º 7
0
 public static Image ExtractZippedImage(string zipFile, string mappath)
 {
     InputStream stream = null;
     ZipFile file = null;
     Image image;
     try
     {
         file = new ZipFile(zipFile);
         Enumeration enumeration = file.entries();
         List<ZipEntry> list = new List<ZipEntry>();
         while (enumeration.hasMoreElements())
         {
             list.Add(enumeration.nextElement() as ZipEntry);
         }
         foreach (ZipEntry entry in list)
         {
             if (entry.getName().EndsWith(Path.GetFileName(mappath)))
             {
                 stream = file.getInputStream(entry);
                 break;
             }
         }
         if (stream == null)
         {
             return ExtractImage(zipFile, mappath);
         }
         Bitmap bitmap = new Bitmap(0x100, 0x100);
         byte[] buffer = new byte[0x40000];
         int index = 0;
         stream.read(new sbyte[0xa5], 0, 0xa5);
         while (index < 0x40000)
         {
             for (int i = 0; i < 0x1000; i++)
             {
                 buffer[index + i] = (byte) stream.read();
             }
             index += 0x1000;
         }
         index = 0;
         int x = 0;
         int y = 0;
         while (index < 0x40000)
         {
             Color color = Color.FromArgb(buffer[index], buffer[index + 3], buffer[index + 2], buffer[index + 1]);
             bitmap.SetPixel(x, y, color);
             x++;
             if (x > 0xff)
             {
                 x = 0;
                 y++;
             }
             index += 4;
         }
         image = bitmap;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         image = null;
     }
     finally
     {
         if (stream != null)
         {
             stream.close();
         }
         if (file != null)
         {
             file.close();
         }
     }
     return image;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Return a list of zip entries (compressed files meta data)
 /// </summary>
 /// <param name="zipFile"></param>
 /// <returns></returns>
 private static List<ZipEntry> getZippedFiles(ZipFile zipFile)
 {
     List<ZipEntry> zipEntries = new List<ZipEntry>();
     java.util.Enumeration zipEnum = zipFile.entries();
     while (zipEnum.hasMoreElements())
     {
         ZipEntry zip = (ZipEntry)zipEnum.nextElement();
         zipEntries.Add(zip);
     }
     return zipEntries;
 }
Exemplo n.º 9
0
        private void RefreshFileCount()
        {
            if (base.LocalFilePath.EndsWith(".zip"))
            {
                ZipFile file = null;
                try
                {
                    file = new ZipFile(base.LocalFilePath);
                    Enumeration enumeration = file.entries();
                    List<ZipEntry> list = new List<ZipEntry>();
                    while (enumeration.hasMoreElements())
                    {
                        list.Add(enumeration.nextElement() as ZipEntry);
                    }
                    int num = 0;
                    foreach (ZipEntry entry in list)
                    {
                        if (!entry.isDirectory())
                        {
                            num++;
                        }
                        if (entry.getName().EndsWith(".exe"))
                        {
                            base.Name = Path.GetFileName(entry.getName());
                            this.ExeName = base.Name;
                            base.Name = base.Name.Remove(base.Name.Length - ".exe".Length, ".exe".Length);
                        }
                    }
                    this.NumberOfFiles = num;
                }
                finally
                {
                    file.close();
                }
            }
            else
            {
                switch (this.PackagingMethod)
                {
                    case PackagingMethods.TargetOnly:
                        this.NumberOfFiles = 1;
                        return;

                    case PackagingMethods.TargetDirectory:
                        this.NumberOfFiles = Directory.GetFiles(Path.GetDirectoryName(base.LocalFilePath), "*.*", SearchOption.TopDirectoryOnly).Length;
                        return;

                    case PackagingMethods.TargetDirectoryRecursive:
                        this.NumberOfFiles = Directory.GetFiles(Path.GetDirectoryName(base.LocalFilePath), "*.*", SearchOption.AllDirectories).Length;
                        return;
                }
            }
        }
Exemplo n.º 10
0
 public bool FromLocalFile(string file, out IAdditionalContent content)
 {
     if (!base.ContentType.CurrentUserCanUpload)
     {
         content = null;
         return false;
     }
     if (file.EndsWith(".exe"))
     {
         base.Name = Path.GetFileName(file);
         this.ExeName = base.Name;
         base.Name = base.Name.Remove(base.Name.Length - ".exe".Length, ".exe".Length);
         this.NumberOfFiles = Directory.GetFiles(Path.GetDirectoryName(file), "*.*", SearchOption.AllDirectories).Length;
     }
     else if (file.EndsWith(".zip"))
     {
         ZipFile file2 = null;
         base.Name = Path.GetFileName(file);
         base.Name = base.Name.Remove(base.Name.Length - ".zip".Length, ".zip".Length);
         try
         {
             file2 = new ZipFile(file);
             Enumeration enumeration = file2.entries();
             List<ZipEntry> list = new List<ZipEntry>();
             while (enumeration.hasMoreElements())
             {
                 list.Add(enumeration.nextElement() as ZipEntry);
             }
             bool flag = false;
             int num = 0;
             foreach (ZipEntry entry in list)
             {
                 if (!entry.isDirectory())
                 {
                     num++;
                 }
                 if (entry.getName().EndsWith(".exe") || entry.getName().EndsWith(".bat"))
                 {
                     this.ExeName = entry.getName();
                     flag = true;
                 }
             }
             if (!flag)
             {
                 content = null;
                 return false;
             }
             this.NumberOfFiles = num;
         }
         finally
         {
             file2.close();
         }
     }
     base.LocalFilePath = file;
     content = this;
     return true;
 }