Renamed file_exists()->path_exists()

This commit is contained in:
gabime 2019-10-25 15:56:23 +03:00
parent c40555c0ac
commit dbe5c17a96
7 changed files with 10 additions and 23 deletions

View File

@ -97,11 +97,6 @@ SPDLOG_INLINE const filename_t &file_helper::filename() const
return _filename;
}
SPDLOG_INLINE bool file_helper::file_exists(const filename_t &fname)
{
return os::file_exists(fname);
}
//
// return file path and its extension:
//

View File

@ -29,7 +29,6 @@ public:
void write(const memory_buf_t &buf);
size_t size() const;
const filename_t &filename() const;
static bool file_exists(const filename_t &fname);
//
// return file path and its extension:

View File

@ -178,7 +178,7 @@ SPDLOG_INLINE int remove(const filename_t &filename) SPDLOG_NOEXCEPT
SPDLOG_INLINE int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT
{
return file_exists(filename) ? remove(filename) : 0;
return path_exists(filename) ? remove(filename) : 0;
}
SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT
@ -190,8 +190,8 @@ SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename
#endif
}
// Return true if file exists
SPDLOG_INLINE bool file_exists(const filename_t &filename) SPDLOG_NOEXCEPT
// Return true if path exists (file or directory)
SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT
{
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
@ -481,7 +481,7 @@ SPDLOG_INLINE bool mkdir_(const filename_t &path)
// return true on success
SPDLOG_INLINE bool create_dir(filename_t path)
{
if (file_exists(path))
if (path_exists(path))
{
return true;
}
@ -503,7 +503,7 @@ SPDLOG_INLINE bool create_dir(filename_t path)
auto subdir = path.substr(0, token_pos);
if (!subdir.empty() && !file_exists(subdir) && !mkdir_(subdir))
if (!subdir.empty() && !path_exists(subdir) && !mkdir_(subdir))
{
return false; // return error if failed creating dir
}

View File

@ -53,7 +53,7 @@ int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT;
// Return if file exists.
bool file_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
// Return file size according to open FILE* object
size_t filesize(FILE *f);

View File

@ -88,11 +88,12 @@ template<typename Mutex>
SPDLOG_INLINE void rotating_file_sink<Mutex>::rotate_()
{
using details::os::filename_to_str;
using details::os::path_exists;
file_helper_.close();
for (auto i = max_files_; i > 0; --i)
{
filename_t src = calc_filename(base_filename_, i - 1);
if (!details::file_helper::file_exists(src))
if (!path_exists(src))
{
continue;
}

View File

@ -4,13 +4,13 @@
#include "includes.h"
using spdlog::details::os::create_dir;
using spdlog::details::os::file_exists;
using spdlog::details::os::path_exists;
bool try_create_dir(const char *path, const char *normalized_path)
{
auto rv = create_dir(path);
REQUIRE(rv == true);
return file_exists(normalized_path);
return path_exists(normalized_path);
}
TEST_CASE("create_dir", "[create_dir]")

View File

@ -38,14 +38,6 @@ TEST_CASE("file_helper_size", "[file_helper::size()]]")
REQUIRE(get_filesize(target_filename) == expected_size);
}
TEST_CASE("file_helper_exists", "[file_helper::file_exists()]]")
{
prepare_logdir();
REQUIRE(!file_helper::file_exists(target_filename));
file_helper helper;
helper.open(target_filename);
REQUIRE(file_helper::file_exists(target_filename));
}
TEST_CASE("file_helper_reopen", "[file_helper::reopen()]]")
{