!33 【OpenHarmony】【轻量级应用程序框架子系统】bms存储文件时增加fsync

Merge pull request !33 from wangdengjia/070202
This commit is contained in:
openharmony_ci
2021-07-02 03:42:06 +00:00
committed by Gitee
2 changed files with 9 additions and 0 deletions
@@ -142,6 +142,7 @@ bool BundleFileUtils::WriteFile(const char *file, const void *buffer, uint32_t s
return false;
}
fsync(fp);
close(fp);
return true;
}
@@ -15,7 +15,11 @@
#include "extractor_util.h"
#include <dirent.h>
#include <fcntl.h>
#include <fstream>
#include <sys/stat.h>
#include <unistd.h>
#include "log.h"
@@ -62,6 +66,10 @@ bool ExtractorUtil::ExtractFileToPath(const std::string &filePath, const std::st
}
fileStream.clear();
fileStream.close();
int fd = open(filePath.c_str(), O_RDWR, S_IRUSR | S_IWUSR);
fsync(fd);
close(fd);
return true;
}