updated build system
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
@ -271,16 +271,12 @@ template <typename string_t>
|
||||
}
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
format_path(api_path, slash_t, backslash_t);
|
||||
|
||||
while (utils::string::begins_with(api_path, dot_slash_t)) {
|
||||
api_path = api_path.substr(dot_slash_t.size());
|
||||
}
|
||||
|
||||
while (utils::string::begins_with(api_path, dot_t)) {
|
||||
api_path = api_path.substr(dot_t.size());
|
||||
}
|
||||
|
||||
format_path(api_path, slash_t, backslash_t);
|
||||
|
||||
if (api_path.at(0U) != slash_t.at(0U)) {
|
||||
return string_t{slash_t} + api_path;
|
||||
}
|
||||
|
@ -110,28 +110,29 @@ auto file::open_file(std::filesystem::path path, bool read_only) -> file {
|
||||
auto file::open_or_create_file(std::filesystem::path path,
|
||||
bool read_only) -> file {
|
||||
path = utils::path::absolute(path.string());
|
||||
|
||||
if (not utils::file::is_file(path.string())) {
|
||||
#if defined(_WIN32)
|
||||
int old_mode{};
|
||||
_umask_s(077, &old_mode);
|
||||
int old_mode{};
|
||||
_umask_s(077, &old_mode);
|
||||
#else // !defined(_WIN32)
|
||||
auto old_mode = umask(077);
|
||||
auto old_mode = umask(077);
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
#if defined(_WIN32)
|
||||
auto *ptr = _fsopen(path.string().c_str(), "ab+", _SH_DENYNO);
|
||||
auto *ptr = _fsopen(path.string().c_str(), "ab+", _SH_DENYNO);
|
||||
#else // !defined(_WIN32)
|
||||
auto *ptr = fopen(path.string().c_str(), "ab+");
|
||||
auto *ptr = fopen(path.string().c_str(), "ab+");
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
#if defined(_WIN32)
|
||||
_umask_s(old_mode, nullptr);
|
||||
_umask_s(old_mode, nullptr);
|
||||
#else // !defined(_WIN32)
|
||||
umask(old_mode);
|
||||
umask(old_mode);
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
if (ptr != nullptr) {
|
||||
fclose(ptr);
|
||||
if (ptr != nullptr) {
|
||||
fclose(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
return open_file(path, read_only);
|
||||
|
@ -114,6 +114,13 @@ TEST(utils_path, combine) {
|
||||
EXPECT_STREQ("/test/path/again", s.c_str());
|
||||
#endif
|
||||
|
||||
s = utils::path::combine("/home/test/.dest", {".state"});
|
||||
#if defined(_WIN32)
|
||||
EXPECT_STREQ("\\home\\test\\.dest\\.state", s.c_str());
|
||||
#else
|
||||
EXPECT_STREQ("/home/test/.dest/.state", s.c_str());
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
s = utils::path::combine(R"(R:\test)", {R"(\path)", R"(\again\)"});
|
||||
EXPECT_STREQ(R"(r:\test\path\again)", s.c_str());
|
||||
@ -200,6 +207,15 @@ TEST(utils_path, create_api_path) {
|
||||
|
||||
s = utils::path::create_api_path("/cow\\\\/moose\\\\/\\dog\\chicken\\");
|
||||
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
|
||||
|
||||
s = utils::path::create_api_path(".state");
|
||||
EXPECT_STREQ("/.state", s.c_str());
|
||||
|
||||
s = utils::path::create_api_path("/.state/.local");
|
||||
EXPECT_STREQ("/.state/.local", s.c_str());
|
||||
|
||||
s = utils::path::create_api_path("./.state/.local");
|
||||
EXPECT_STREQ("/.state/.local", s.c_str());
|
||||
}
|
||||
|
||||
TEST(utils_path, finalize) {
|
||||
|
Reference in New Issue
Block a user