NativeCFFI doesn’t include some fields into compilation when using macros which causes errors when using FileSystem.readDirectory:
System.hx:713: characters 19-58 : Class<lime._backend.native.NativeCFFI> has no field lime_system_get_device_model
System.hx:744: characters 20-60 : Class<lime._backend.native.NativeCFFI> has no field lime_system_get_device_vendor
System.hx:841: characters 22-63 : Class<lime._backend.native.NativeCFFI> has no field lime_system_get_platform_label
System.hx:905: characters 23-66 : Class<lime._backend.native.NativeCFFI> has no field lime_system_get_platform_version
ThreadPool.hx:26: characters 21-49 : Unknown<0> cannot be constructed
The macro I’m trying to run:
public static macro function encodeImages(expr : Expr) : Expr {
var sourceFiles : Array<String> = FileSystem.readDirectory(SPRITESHEET_DIR);
for (src in sourceFiles){
var dot = src.indexOf(".");
if (src.substring(dot, src.length) != ".png")
continue;
var filename = src.substring(0, dot);
var srcFile = sys.io.File.read(SPRITESHEET_DIR + src);
var srcBytes = BinaryCoder.encode(srcFile.readAll());
srcFile.close();
var dstFile = sys.io.File.write(GFX_DIR + filename + ".art");
dstFile.writeBytes(srcBytes, 0, srcBytes.length);
dstFile.close();
}
return expr;
}