Hi List or Group,
I've a problem unzipping my files and kinda stuck here.. as long it´s simple data e.g. one zip file with a few files in it i´m completly fine and everything works but as soon as I come to a folder inside my zip-file I´m out..
static function main() {
//creating folder for unzipped data
if (! sys.FileSystem.exists('C:\\test\\TestZip\\unzipped')) {
sys.FileSystem.createDirectory('C:\\test\\TestZip\\unzipped');
}
var fileIn = sys.io.File.read('C:\\test\\TestZip\\testZip.zip', true);
var zipDat = haxe.zip.Reader.readZip(fileIn);
try {
trace(zipDat);
for (s in zipDat) {
trace(s.fileName);
var content = (s.compressed) ? haxe.zip.Reader.unzip(s) : s.data;
trace(content);
if (content.length != 0) {
//here lays my problem I can#t tell for sure if it´s a folder or just an empty file
//if it´s an folder I need too create it first, before unzipping anything into it
//but i don't see any flags??
sys.io.File.saveBytes('C:\\test\\TestZip\\unzipped\\' + s.fileName, content);
}
}
fileIn.close();
zipDat.clear();
} catch (e: Dynamic) {
trace(e);
}
}
As in code, I guess I need too create the folder first, before unzipping my content too it. But as I can't tell if it's a empty file or an folder, I don't know when too create an folder?
I tried with content.length but empty files have also the length == 0, I even thougt about scanning the filename for an dot, but you can have dots in folders and you can files without a dot..
Maybe I´m generally doing something terrible wrong and there are better ways for file-handling and unzipping in neko?