diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-01-11 02:25:40 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-01-11 02:25:40 +0100 |
commit | b1d00fce8da901b31fa52ea59b4bc3c8edb9d9cc (patch) | |
tree | f7c909b4080e6d1868e601609741450330dc9a1e /java/javautils.cpp | |
parent | d6d5c86a736537828a59ddc6389d5d0490942f8c (diff) | |
download | PrismLauncher-b1d00fce8da901b31fa52ea59b4bc3c8edb9d9cc.tar.gz PrismLauncher-b1d00fce8da901b31fa52ea59b4bc3c8edb9d9cc.tar.bz2 PrismLauncher-b1d00fce8da901b31fa52ea59b4bc3c8edb9d9cc.zip |
CMake build system, big pile of libs: bspatch, quazip, java, the launcher
Diffstat (limited to 'java/javautils.cpp')
-rw-r--r-- | java/javautils.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/java/javautils.cpp b/java/javautils.cpp new file mode 100644 index 00000000..a07d1541 --- /dev/null +++ b/java/javautils.cpp @@ -0,0 +1,69 @@ +#include "multimc_pragma.h" +#include "classfile.h" +#include "javautils.h" +//#include <wx/zipstrm.h> +#include <memory> +//#include <wx/wfstream.h> +//#include "mcversionlist.h" + +namespace javautils +{ +QString GetMinecraftJarVersion(QString jar) +{ + return "Unknown"; + /* + wxString fullpath = jar.GetFullPath(); + wxString version = MCVer_Unknown; + if(!jar.FileExists()) + return version; + std::auto_ptr<wxZipEntry> entry; + // convert the local name we are looking for into the internal format + wxString name = wxZipEntry::GetInternalName("net/minecraft/client/Minecraft.class",wxPATH_UNIX); + + // open the zip + wxFFileInputStream inStream(jar.GetFullPath()); + wxZipInputStream zipIn(inStream); + + // call GetNextEntry() until the required internal name is found + do + { + entry.reset(zipIn.GetNextEntry()); + } + while (entry.get() != NULL && entry->GetInternalName() != name); + auto myentry = entry.get(); + if (myentry == NULL) + return version; + + // we got the entry, read the data + std::size_t size = myentry->GetSize(); + char *classdata = new char[size]; + zipIn.Read(classdata,size); + try + { + char * temp = classdata; + java::classfile Minecraft_jar(temp,size); + auto cnst = Minecraft_jar.constants; + auto iter = cnst.begin(); + while (iter != cnst.end()) + { + const java::constant & constant = *iter; + if(constant.type != java::constant::j_string_data) + { + iter++; + continue; + } + auto & str = constant.str_data; + const char * lookfor = "Minecraft Minecraft "; // length = 20 + if(str.compare(0,20,lookfor) == 0) + { + version = str.substr(20).data(); + break; + } + iter++; + } + } catch(java::classfile_exception &){} + delete[] classdata; + return version; + */ +} +}
\ No newline at end of file |