我正在关注这个例子:https ://stackoverflow.com/a/41713258/2330482
但是,重新启动应用程序后无法读取该文件,因此我在设备管理器中进行了检查 - 该文件夹未出现在 /opt/usr/home/owner/apps_rw/org.example.basicui/data/ 中。我已经cd
进入.basicui
目录并ls - l
给出
sh-3.2$ cd apps_rw
sh-3.2$ cd org.example.basicui
sh-3.2$ ls -l
ls: cannot access cache: Permission denied
ls: cannot access data: Permission denied
total 8
lrwxrwxrwx 1 app_fw app_fw 60 Sep 2 21:31 author-signature.xml -> /opt/usr/globalapps/org.example.basicui/author-signature.xml
lrwxrwxrwx 1 app_fw app_fw 43 Sep 2 21:31 bin -> /opt/usr/globalapps/org.example.basicui/bin
d????????? ? ? ? ? ? cache
d????????? ? ? ? ? ? data
lrwxrwxrwx 1 app_fw app_fw 43 Sep 2 21:31 lib -> /opt/usr/globalapps/org.example.basicui/lib
lrwxrwxrwx 1 app_fw app_fw 43 Sep 2 21:31 res -> /opt/usr/globalapps/org.example.basicui/res
drwxr-xr-x 3 owner users 4096 Sep 2 21:31 shared
lrwxrwxrwx 1 app_fw app_fw 58 Sep 2 21:31 tizen-manifest.xml -> /opt/usr/globalapps/org.example.basicui/tizen-manifest.xml
sh-3.2$ whoami
owner
我的代码如下:
char* get_write_filepath(char *filename)
{
char write_filepath[1000] = {0,};
char *resource_path = app_get_data_path(); // get the application data directory path
if(resource_path)
{
snprintf(write_filepath,1000,"%s%s",resource_path,filename);
free(resource_path);
}
return write_filepath;
}
static char* write_file(const char* filepath, const char* buf)
{
FILE *fp;
fp = fopen(filepath,"w");
fputs(buf,fp);
fclose(fp);
dlog_print(DLOG_DEBUG, "AAAMYTAG", "written");
}
void saveExampleFile() {
dlog_print(DLOG_DEBUG, "AAAMYTAG", "save example file");
char *filepath;
filepath=get_write_filepath("d.txt");
write_file(filepath,"TEST");
}
static void //B Button
btn_go_cb(void *data, Evas_Object *obj, void *event_info)
{
dlog_print(DLOG_INFO, "AAAMYTAG", "GO successful.");
saveExampleFile();
}
我哪里错了?文件夹不应该data
是永久的吗?这可能是模拟器错误吗?