diff --git a/README.md b/README.md index 47e7b3d..4f21f78 100644 --- a/README.md +++ b/README.md @@ -40,15 +40,18 @@ evolved with C++11 and the following standards. Keep on the good work! It should work on any of these with a C++11-capable compiler. I currently don't have a BSD derivate besides macOS, so the preprocessor checks will cry out if you try to use it there, but if there is demand, I can try to -help. Still, it shouldn't replace `std::filesystem` where full C++17 is -available, it doesn't try to be a "better" `std::filesystem`, just a drop-in -if you can't use it. +help. Also there are some checks to hopefully better work on Android, but +as I currently don't test with the Android NDK, I wouldn't call it a +supported platform yet. All in all, I don't see it replacing `std::filesystem` +where full C++17 is available, it doesn't try to be a "better" +`std::filesystem`, just a drop-in if you can't use it (with the exception +of the UTF-8 preference on Windows). Tests are currently run with: * macOS 10.12: XCode 9.2 (clang-900.0.39.2), GCC 8.1.0, Clang 7.0.0 * Windows 10: Visual Studio 2017 15.8.5, MingW GCC 5.3 -* Linux: Ubuntu 18.04LTS GCC 7.3 & GCC 8.0.1 +* Linux: Ubuntu 18.04LTS GCC 7.3 & GCC 8.2.0 ## Tests @@ -72,11 +75,12 @@ make This generates `filesystem_test`, the binary that runs all tests. If the default compiler is a GCC 8 or newer, or Clang 7 or newer, it -additionally builds a version of the test binary compiled against GCCs/Clangs +additionally tries to build a version of the test binary compiled against GCCs/Clangs `std::filesystem` implementation, named `std_filesystem_test` as an additional test of conformance. Ideally all tests should compile and succeed with all filesystem implementations, but in reality, there are -some differences in behavior and might be issues in these implementations. +some differences in behavior, sometimes due to room for interpretation in +in the standard, and there might be issues in these implementations too. ## Usage @@ -355,6 +359,8 @@ to the expected behavior. * Bugfix for ([#9](https://github.com/gulrak/filesystem/issues/9)), added missing return statement to `ghc::filesystem::path::generic_string()` +* Added checks to hopefully better compile against Android NDK. There where + no tests run yet, so feedback is needed to actually call this supported. ### [v1.0.8](https://github.com/gulrak/filesystem/releases/tag/v1.0.8) diff --git a/examples/dir.cpp b/examples/dir.cpp index a03790c..0b0c03f 100644 --- a/examples/dir.cpp +++ b/examples/dir.cpp @@ -21,7 +21,7 @@ std::time_t to_time_t(TP tp) static std::string perm_to_str(fs::perms prms) { std::string result; - result.reserve(6); + result.reserve(9); for(int i = 0; i < 9; ++i) { result = ((static_cast(prms) & (1< #include #include +#if defined(__ANDROID__) +#define GHC_OS_ANDROID +#include +#endif #endif #ifdef GHC_OS_MACOS #include @@ -1276,14 +1280,14 @@ inline std::string systemErrorText(ErrorNumber code = 0) std::string msg = toUtf8(std::wstring((LPWSTR)msgBuf)); LocalFree(msgBuf); return msg; -#elif defined(GHC_OS_LINUX) +#elif defined(GHC_OS_MACOS) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)) || (defined(GHC_OS_ANDROID) && __ANDROID_API__<23) + char buffer[512]; + int rc = strerror_r(code ? code : errno, buffer, sizeof(buffer)); + return rc == 0 ? (const char*)buffer : "Error in strerror_r!" +#else char buffer[512]; char* msg = strerror_r(code ? code : errno, buffer, sizeof(buffer)); return msg ? msg : buffer; -#elif defined(GHC_OS_MACOS) - char buffer[512]; - int rc = strerror_r(code ? code : errno, buffer, sizeof(buffer)); - return rc == 0 ? (const char*)buffer : "Error in strerror_r!"; #endif } @@ -1679,10 +1683,14 @@ inline u8arguments::u8arguments(int& argc, char**& argv) _isvalid = true; #else std::setlocale(LC_ALL, ""); +#if defined(__ANDROID__) && __ANDROID_API__ < 26 + _isvalid = true; +#else if (!detail::compare_no_case(::nl_langinfo(CODESET), "UTF-8")) { _isvalid = true; } #endif +#endif } //----------------------------------------------------------------------------- @@ -3800,13 +3808,16 @@ inline space_info space(const path& p, std::error_code& ec) noexcept return {static_cast(-1), static_cast(-1), static_cast(-1)}; } return {static_cast(totalNumberOfBytes.QuadPart), static_cast(totalNumberOfFreeBytes.QuadPart), static_cast(freeBytesAvailableToCaller.QuadPart)}; -#else +#elif !defined(__ANDROID__) || __ANDROID_API__ >= 19 struct ::statvfs sfs; if (::statvfs(p.c_str(), &sfs) != 0) { ec = std::error_code(errno, std::system_category()); return {static_cast(-1), static_cast(-1), static_cast(-1)}; } return {static_cast(sfs.f_blocks * sfs.f_frsize), static_cast(sfs.f_bfree * sfs.f_frsize), static_cast(sfs.f_bavail * sfs.f_frsize)}; +#else + ec = detail::make_error_code(detail::portable_error::not_supported); + return {static_cast(-1), static_cast(-1), static_cast(-1)}; #endif }