Unzipping a folder with Haxe

95 views
Skip to first unread message

Mark Beiline

unread,
Jun 4, 2014, 7:02:31 PM6/4/14
to haxe...@googlegroups.com
I'm trying to write an updater. Essentially, it has to fetch a zip from an URL and then unzip its contents into the updater's directory. Everything's working, but the unzipped files don't have the right format. I can't open the .exes because "This file is not compatible with the version of Windows you're running" - essentially it's corrupt. The ndlls are also not right, and .txt files are scrambled. The only files that appear proper are images.

in my code I call loadZip which then calls createFile. These two functions are all that deal with zipping/unzipping.

BTW I'm compiling to Windows C++ target.

public static function loadZip():Void
 
{
 
var bytes:Bytes = File.getBytes("SkullClient.zip");
 
var bytesInput = new BytesInput(bytes);
 
 
var reader = new Reader(bytesInput);
 
var entries:List<Entry> = reader.read();          
 
var searchEntryFileName = "path/to/textfile.txt";
 
for (entry in entries ) {
 
//if (entry.fileName == searchEntryFileName) {
 createFile
(entry);
 
//}
 
}
 
}
 
 
public static function createFile(E:Entry):Void
 
{
 
var path:String = Path.join([Path.directory(Sys.executablePath()), E.fileName]);
 
if (path.charAt(path.length - 1) == "/")
 
{
 
FileSystem.createDirectory(path);
 
}
 
 
else
 
{
 
var fileo:FileOutput = File.write(path);
 fileo
.write(E.data);
 
}
 
}

Sven Bergström

unread,
Jun 7, 2014, 3:37:25 PM6/7/14
to haxe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages