summaryrefslogtreecommitdiffstats
path: root/java/javautils.cpp
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-01-25 12:35:14 -0600
committerAndrew <forkk@forkk.net>2013-01-25 12:35:14 -0600
commitf5ee069ea989a07915eb20c62ec4e812dfa9e701 (patch)
tree7d2895bf49925aa6ef7cc91caf9a01de694b2eee /java/javautils.cpp
parent3b422b54aa13be4eb59c80b1f7bb2a514aac583f (diff)
parent00893b3cfc68f12c09e84643d255044a488b0eb6 (diff)
downloadMultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar
MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar.gz
MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar.lz
MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar.xz
MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.zip
Merge branch 'master' of git://github.com/peterix/MultiMC5
Diffstat (limited to 'java/javautils.cpp')
-rw-r--r--java/javautils.cpp69
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