源代码已经在Fedora 15,16和Ubuntu 10,11,12中进行了测试,没有问题。
但是在 Fedora 17 中,文件写入功能不起作用。
1)
int fd;
if ( 0 < ( fd = open("/home/test/temp/opentest.html", O_CREAT | O_EXCL, 0777))) {
write(fd, "test", strlen("test"));
close(fd);
return "Success";
} else {
return "Error";
}
返回值:错误
2)
FILE *pFile;
pFile = fopen("/home/test/temp/opentest.html", "w+");
if (pFile == NULL) {
return "Pointer is NULL";
} else {
fputs("fopen test", pFile);
fclose(pFile);
return "Success";
}
返回值:"指针为 NULL"
我猜目录的权限出错并设置了 777 权限。但什么都没有改变。
相同的代码在普通的C程序中工作。
为什么它在火息 npPlugin 中不起作用?
许可有什么区别吗?
最有可能的是,该目录不存在,或者您没有写入它的权限。
此命令有效吗?
echo 123 > /home/test/temp/opentest.html