mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-07-21 18:24:25 +08:00
refs #18, fighting VS2015 sfinae issues
This commit is contained in:
parent
15788d8eb9
commit
aa1cb70816
@ -1,12 +1,16 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include(<filesystem>)
|
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)
|
||||||
|
#if __has_include(<filesystem>)
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
#else
|
#define GHC_USE_STD_FS
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef GHC_USE_STD_FS
|
||||||
#include <ghc/filesystem.hpp>
|
#include <ghc/filesystem.hpp>
|
||||||
namespace fs = ghc::filesystem;
|
namespace fs = ghc::filesystem;
|
||||||
#endif
|
#endif
|
||||||
@ -49,11 +53,8 @@ int main(int argc, char* argv[])
|
|||||||
for (auto de : fs::directory_iterator(dir)) {
|
for (auto de : fs::directory_iterator(dir)) {
|
||||||
auto ft = to_time_t(de.last_write_time());
|
auto ft = to_time_t(de.last_write_time());
|
||||||
auto ftm = *std::localtime(&ft);
|
auto ftm = *std::localtime(&ft);
|
||||||
std::cout << (de.is_directory() ? "d" : "-") << perm_to_str(de.symlink_status().permissions()) << " "
|
std::cout << (de.is_directory() ? "d" : "-") << perm_to_str(de.symlink_status().permissions()) << " " << std::setw(8) << (de.is_directory() ? "-" : std::to_string(de.file_size())) << " " << std::put_time(&ftm, "%Y-%m-%d %H:%M:%S") << " "
|
||||||
<< std::setw(8) << (de.is_directory() ? "-" : std::to_string(de.file_size())) << " "
|
<< de.path().filename().string() << std::endl;
|
||||||
<< std::put_time(&ftm, "%Y-%m-%d %H:%M:%S") << " "
|
|
||||||
<< de.path().filename().string()
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include(<filesystem>)
|
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)
|
||||||
|
#if __has_include(<filesystem>)
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
#else
|
#define GHC_USE_STD_FS
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef GHC_USE_STD_FS
|
||||||
#include <ghc/filesystem.hpp>
|
#include <ghc/filesystem.hpp>
|
||||||
namespace fs = ghc::filesystem;
|
namespace fs = ghc::filesystem;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1296,13 +1296,13 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 1)>::type* = nullptr>
|
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 1), int>::type size = 1>
|
||||||
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
||||||
{
|
{
|
||||||
return std::string(unicodeString.begin(), unicodeString.end());
|
return std::string(unicodeString.begin(), unicodeString.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 2)>::type* = nullptr>
|
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 2), int>::type size = 2>
|
||||||
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
@ -1324,7 +1324,7 @@ inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicode
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 4)>::type* = nullptr>
|
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 4), int>::type size = 4>
|
||||||
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
@ -1334,10 +1334,10 @@ inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicode
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename SourceType>
|
template <typename charT>
|
||||||
inline std::string toUtf8(const SourceType* unicodeString)
|
inline std::string toUtf8(const charT* unicodeString)
|
||||||
{
|
{
|
||||||
return toUtf8(std::basic_string<SourceType, std::char_traits<SourceType>>(unicodeString));
|
return toUtf8(std::basic_string<charT, std::char_traits<charT>>(unicodeString));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
Loading…
x
Reference in New Issue
Block a user