我正在使用 FlasCC+Swig 在 Adobe Air 应用程序中调用我的 C 函数。
C函数:
int file_exists(const char filename[]) {
struct stat stbuf;
if (stat(filename, &stbuf) == -1) {
return (0);
}
return (1);
}
在我的普通命令行中(当然,首先编译一个main.cpp),如果我提供“/tmp/test.txt”(文件存在),函数file_exists
返回1,这是预期的。
但是,我用FlasCC+Swig编译这个C函数file_exists
,生成一个swc库,把这个库添加到我的Adobe Air应用程序中运行后,总是返回0,这是不正确的。
我检查了errno
,它的值是ENOENT (2)
:
路径的组件没有命名现有文件或路径是空字符串。
http://pubs.opengroup.org/onlinepubs/7908799/xsh/stat.html
你能给我一些想法吗?
顺便说一句,在我的 Adobe Air 应用程序中:
var file:File = File.applicationDirectory.resolvePath(path);
trace(file.exists); // returns true
所以 Adobe Air 确实可以访问本地文件系统。