Commit dbe5c17a authored by gabime's avatar gabime

Renamed file_exists()->path_exists()

parent c40555c0
...@@ -97,11 +97,6 @@ SPDLOG_INLINE const filename_t &file_helper::filename() const ...@@ -97,11 +97,6 @@ SPDLOG_INLINE const filename_t &file_helper::filename() const
return _filename; return _filename;
} }
SPDLOG_INLINE bool file_helper::file_exists(const filename_t &fname)
{
return os::file_exists(fname);
}
// //
// return file path and its extension: // return file path and its extension:
// //
......
...@@ -29,7 +29,6 @@ public: ...@@ -29,7 +29,6 @@ public:
void write(const memory_buf_t &buf); void write(const memory_buf_t &buf);
size_t size() const; size_t size() const;
const filename_t &filename() const; const filename_t &filename() const;
static bool file_exists(const filename_t &fname);
// //
// return file path and its extension: // return file path and its extension:
......
...@@ -178,7 +178,7 @@ SPDLOG_INLINE int remove(const filename_t &filename) SPDLOG_NOEXCEPT ...@@ -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 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 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 ...@@ -190,8 +190,8 @@ SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename
#endif #endif
} }
// Return true if file exists // Return true if path exists (file or directory)
SPDLOG_INLINE bool file_exists(const filename_t &filename) SPDLOG_NOEXCEPT SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT
{ {
#ifdef _WIN32 #ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES #ifdef SPDLOG_WCHAR_FILENAMES
...@@ -481,7 +481,7 @@ SPDLOG_INLINE bool mkdir_(const filename_t &path) ...@@ -481,7 +481,7 @@ SPDLOG_INLINE bool mkdir_(const filename_t &path)
// return true on success // return true on success
SPDLOG_INLINE bool create_dir(filename_t path) SPDLOG_INLINE bool create_dir(filename_t path)
{ {
if (file_exists(path)) if (path_exists(path))
{ {
return true; return true;
} }
...@@ -503,7 +503,7 @@ SPDLOG_INLINE bool create_dir(filename_t path) ...@@ -503,7 +503,7 @@ SPDLOG_INLINE bool create_dir(filename_t path)
auto subdir = path.substr(0, token_pos); 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 return false; // return error if failed creating dir
} }
......
...@@ -53,7 +53,7 @@ int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT; ...@@ -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; int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT;
// Return if file exists. // 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 // Return file size according to open FILE* object
size_t filesize(FILE *f); size_t filesize(FILE *f);
......
...@@ -88,11 +88,12 @@ template<typename Mutex> ...@@ -88,11 +88,12 @@ template<typename Mutex>
SPDLOG_INLINE void rotating_file_sink<Mutex>::rotate_() SPDLOG_INLINE void rotating_file_sink<Mutex>::rotate_()
{ {
using details::os::filename_to_str; using details::os::filename_to_str;
using details::os::path_exists;
file_helper_.close(); file_helper_.close();
for (auto i = max_files_; i > 0; --i) for (auto i = max_files_; i > 0; --i)
{ {
filename_t src = calc_filename(base_filename_, i - 1); filename_t src = calc_filename(base_filename_, i - 1);
if (!details::file_helper::file_exists(src)) if (!path_exists(src))
{ {
continue; continue;
} }
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
#include "includes.h" #include "includes.h"
using spdlog::details::os::create_dir; 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) bool try_create_dir(const char *path, const char *normalized_path)
{ {
auto rv = create_dir(path); auto rv = create_dir(path);
REQUIRE(rv == true); REQUIRE(rv == true);
return file_exists(normalized_path); return path_exists(normalized_path);
} }
TEST_CASE("create_dir", "[create_dir]") TEST_CASE("create_dir", "[create_dir]")
......
...@@ -38,14 +38,6 @@ TEST_CASE("file_helper_size", "[file_helper::size()]]") ...@@ -38,14 +38,6 @@ TEST_CASE("file_helper_size", "[file_helper::size()]]")
REQUIRE(get_filesize(target_filename) == expected_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()]]") TEST_CASE("file_helper_reopen", "[file_helper::reopen()]]")
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment