Changed tmpnam with mkdtemp

Reviewers: dgleich, buda

Reviewed By: dgleich

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D431
This commit is contained in:
matej.gradicek 2017-06-16 07:34:46 +00:00
parent 527d69d382
commit c820b25c9c
3 changed files with 12 additions and 6 deletions

View File

@ -11,7 +11,8 @@ DECLARE_int32(snapshot_cycle_sec);
namespace fs = std::experimental::filesystem;
const fs::path SNAPSHOTS_DBMS_RECOVERY_ALL_DB = std::tmpnam(nullptr);
char tmp[] = "XXXXXX";
const fs::path SNAPSHOTS_DBMS_RECOVERY_ALL_DB = mkdtemp(tmp);
const fs::path SNAPSHOTS_DBMS_RECOVERY_DEFAULT_DB_DIR =
SNAPSHOTS_DBMS_RECOVERY_ALL_DB / "default";

View File

@ -14,7 +14,10 @@ DECLARE_int32(snapshot_cycle_sec);
namespace fs = std::experimental::filesystem;
const fs::path SNAPSHOTS_RECOVERY_DEFAULT_DB_DIR = std::tmpnam(nullptr);
char tmp[] = "XXXXXX";
const fs::path SNAPSHOTS_RECOVERY_ALL_DB_DIR = mkdtemp(tmp);
const fs::path SNAPSHOTS_RECOVERY_DEFAULT_DB_DIR =
SNAPSHOTS_RECOVERY_ALL_DB_DIR / "default";
std::vector<fs::path> GetFilesFromDir(
const std::string &snapshots_default_db_dir) {

View File

@ -12,13 +12,15 @@ DECLARE_string(snapshot_directory);
namespace fs = std::experimental::filesystem;
const std::string SNAPSHOTS_FOLDER_ALL_DB = "snapshots_test";
const std::string SNAPSHOTS_TEST_DEFAULT_DB_DIR = "snapshots_test/default";
char tmp[] = "XXXXXX";
const fs::path SNAPSHOTS_FOLDER_ALL_DB = mkdtemp(tmp);
const fs::path SNAPSHOTS_TEST_DEFAULT_DB_DIR =
SNAPSHOTS_FOLDER_ALL_DB / "default";
// Other functionality will be tested in recovery tests.
// Other functionality is tested in recovery tests.
std::vector<fs::path> GetFilesFromDir(
const std::string &snapshots_default_db_dir) {
const fs::path &snapshots_default_db_dir) {
std::vector<fs::path> files;
for (auto &file : fs::directory_iterator(snapshots_default_db_dir))
files.push_back(file.path());