Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:32:27

0001 // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
0002 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
0003 
0004 #pragma once
0005 
0006 #include <ctime>  // std::time_t
0007 #include <spdlog/common.h>
0008 
0009 namespace spdlog {
0010 namespace details {
0011 namespace os {
0012 
0013 SPDLOG_API spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT;
0014 
0015 SPDLOG_API std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
0016 
0017 SPDLOG_API std::tm localtime() SPDLOG_NOEXCEPT;
0018 
0019 SPDLOG_API std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
0020 
0021 SPDLOG_API std::tm gmtime() SPDLOG_NOEXCEPT;
0022 
0023 // eol definition
0024 #if !defined(SPDLOG_EOL)
0025     #ifdef _WIN32
0026         #define SPDLOG_EOL "\r\n"
0027     #else
0028         #define SPDLOG_EOL "\n"
0029     #endif
0030 #endif
0031 
0032 SPDLOG_CONSTEXPR static const char *default_eol = SPDLOG_EOL;
0033 
0034 // folder separator
0035 #if !defined(SPDLOG_FOLDER_SEPS)
0036     #ifdef _WIN32
0037         #define SPDLOG_FOLDER_SEPS "\\/"
0038     #else
0039         #define SPDLOG_FOLDER_SEPS "/"
0040     #endif
0041 #endif
0042 
0043 SPDLOG_CONSTEXPR static const char folder_seps[] = SPDLOG_FOLDER_SEPS;
0044 SPDLOG_CONSTEXPR static const filename_t::value_type folder_seps_filename[] =
0045     SPDLOG_FILENAME_T(SPDLOG_FOLDER_SEPS);
0046 
0047 // fopen_s on non windows for writing
0048 SPDLOG_API bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode);
0049 
0050 // Remove filename. return 0 on success
0051 SPDLOG_API int remove(const filename_t &filename) SPDLOG_NOEXCEPT;
0052 
0053 // Remove file if exists. return 0 on success
0054 // Note: Non atomic (might return failure to delete if concurrently deleted by other process/thread)
0055 SPDLOG_API int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
0056 
0057 SPDLOG_API int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT;
0058 
0059 // Return if file exists.
0060 SPDLOG_API bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
0061 
0062 // Return file size according to open FILE* object
0063 SPDLOG_API size_t filesize(FILE *f);
0064 
0065 // Return utc offset in minutes or throw spdlog_ex on failure
0066 SPDLOG_API int utc_minutes_offset(const std::tm &tm = details::os::localtime());
0067 
0068 // Return current thread id as size_t
0069 // It exists because the std::this_thread::get_id() is much slower(especially
0070 // under VS 2013)
0071 SPDLOG_API size_t _thread_id() SPDLOG_NOEXCEPT;
0072 
0073 // Return current thread id as size_t (from thread local storage)
0074 SPDLOG_API size_t thread_id() SPDLOG_NOEXCEPT;
0075 
0076 // This is avoid msvc issue in sleep_for that happens if the clock changes.
0077 // See https://github.com/gabime/spdlog/issues/609
0078 SPDLOG_API void sleep_for_millis(unsigned int milliseconds) SPDLOG_NOEXCEPT;
0079 
0080 SPDLOG_API std::string filename_to_str(const filename_t &filename);
0081 
0082 SPDLOG_API int pid() SPDLOG_NOEXCEPT;
0083 
0084 // Determine if the terminal supports colors
0085 // Source: https://github.com/agauniyal/rang/
0086 SPDLOG_API bool is_color_terminal() SPDLOG_NOEXCEPT;
0087 
0088 // Determine if the terminal attached
0089 // Source: https://github.com/agauniyal/rang/
0090 SPDLOG_API bool in_terminal(FILE *file) SPDLOG_NOEXCEPT;
0091 
0092 #if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
0093 SPDLOG_API void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target);
0094 
0095 SPDLOG_API void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target);
0096 #endif
0097 
0098 // Return directory name from given path or empty string
0099 // "abc/file" => "abc"
0100 // "abc/" => "abc"
0101 // "abc" => ""
0102 // "abc///" => "abc//"
0103 SPDLOG_API filename_t dir_name(const filename_t &path);
0104 
0105 // Create a dir from the given path.
0106 // Return true if succeeded or if this dir already exists.
0107 SPDLOG_API bool create_dir(const filename_t &path);
0108 
0109 // non thread safe, cross platform getenv/getenv_s
0110 // return empty string if field not found
0111 SPDLOG_API std::string getenv(const char *field);
0112 
0113 // Do fsync by FILE objectpointer.
0114 // Return true on success.
0115 SPDLOG_API bool fsync(FILE *fp);
0116 
0117 }  // namespace os
0118 }  // namespace details
0119 }  // namespace spdlog
0120 
0121 #ifdef SPDLOG_HEADER_ONLY
0122     #include "os-inl.h"
0123 #endif