android是一种linux,它必须支持posix。但是,当它似乎不支持系统调用时,open()。这是测试代码,我通过NDK编译它:
#include <unistd.h>
#include <stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
void main(){
int fd;
char pathname[128] = "/data/pwrite.txt";
fd = open(pathname, O_WRONLY);
if(fd==-1){
printf("open fail.\n");
}
perror("/data/pwrite.txt");
}
以下是来自android的提示:
kaiwii@ubuntu:~$ adb shell /data/pwrite/test1
open fail.
/data/pwrite.txt: No such file or directory