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);
}
}