我想獲得某種持久性與emscripten工作...Emscripten和持久性
我試圖做(作爲一個概念證明)是每一個頁面被擊中時的時間添加到文件的末尾
目前似乎每次創建該文件的運行...
這裏的代碼的相關位
EM_ASM(
FS.mkdir('/IDBFS');
FS.mount(IDBFS, {}, '/IDBFS');
FS.syncfs(true, function (err) {
assert(!err);
}); // sync FROM backing store
);
int c;
FILE *file;
file = fopen("/IDBFS/test.txt", "a");
if (file) {
time_t rawtime;
struct tm * timeinfo;
time (&rawtime);
timeinfo = localtime (&rawtime);
fprintf (file, "time:%s\n", asctime (timeinfo));
fclose(file);
EM_ASM(
FS.syncfs(function (err) { // sync TO backing store
assert(!err);
});
);
file = fopen("/IDBFS/test.txt", "r");
while ((c = getc(file)) != EOF)
printf("%c",c);
fclose(file);
}
作爲一個完整性檢查,我刪除了所有emscripten特定的東西,並作爲本地應用程序運行。它的行爲如我所料 - 每次運行都會將時間添加到文件中,並且不會重新創建文件 –