android fix
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "sys.hpp"
|
||||
#include "DnaStore.hpp"
|
||||
@@ -15,10 +16,12 @@
|
||||
#define ID_FILE_NAME "ID.bin"
|
||||
#define DATA_FILE_NAME "DATA.bin"
|
||||
#define VECTOR_FILE_NAME "VECTOR.bin"
|
||||
#define GEN_FILE_PATTRN "gen%04d.bin"
|
||||
#define GEN_FILE_PATTRN "gen/%04d.bin"
|
||||
|
||||
void DnaStore::load(DnaManagerData *data)
|
||||
{
|
||||
const char *dir = sys::transformFilePath("gen");
|
||||
std::filesystem::create_directory(dir);
|
||||
if (sys::fileExists(ID_FILE_NAME))
|
||||
{
|
||||
sys::loadDataFromFile(ID_FILE_NAME, &data->id, sizeof(int64_t));
|
||||
@@ -160,8 +163,7 @@ void DnaStore::sync()
|
||||
|
||||
void client(std::string prefix)
|
||||
{
|
||||
|
||||
constexpr int extra_buff = 20; // len of 2**31 -> 2147483648 plus the pattern size
|
||||
constexpr int extra_buff = 22; // len of 2**31 -> 2147483648 plus the pattern size
|
||||
std::string buffer;
|
||||
buffer.resize(prefix.size() + extra_buff);
|
||||
|
||||
@@ -173,7 +175,12 @@ void client(std::string prefix)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
int ret = sprintf(buffer.data(), "%s/" ID_FILE_NAME, prefix.c_str());
|
||||
#else
|
||||
int ret = sprintf(buffer.data(), ID_FILE_NAME);
|
||||
#endif
|
||||
|
||||
buffer.data()[ret] = 0;
|
||||
std::ifstream idf(buffer, std::ios_base::binary);
|
||||
|
||||
@@ -203,7 +210,12 @@ void client(std::string prefix)
|
||||
|
||||
needed_gen = message.data;
|
||||
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
int ret = sprintf(buffer.data(), "%s/" GEN_FILE_PATTRN, prefix.c_str(), needed_gen);
|
||||
#else
|
||||
int ret = sprintf(buffer.data(), GEN_FILE_PATTRN, needed_gen);
|
||||
#endif
|
||||
|
||||
buffer.data()[ret] = 0;
|
||||
|
||||
if (!std::filesystem::exists(buffer))
|
||||
|
Reference in New Issue
Block a user