use std::filesystem instead of std::experimental::filesystem

This commit is contained in:
Jinhao 2018-12-15 10:48:16 +08:00
parent 186b76e765
commit fb7a16bc61
15 changed files with 68 additions and 39 deletions

View File

@ -538,13 +538,20 @@ namespace std {
namespace filesystem {
using namespace std::experimental::filesystem;
#if (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)))
#if defined(NANA_FILESYSTEM_FORCE) || \
(defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)))
path absolute(const path& p);
path absolute(const path& p, std::error_code& err);
path canonical(const path& p);
path canonical(const path& p, std::error_code& err);
#endif
#if defined(NANA_FILESYSTEM_FORCE) || defined(NANA_MINGW)
bool exists( std::filesystem::file_status s ) noexcept;
bool exists( const std::filesystem::path& p );
bool exists( const std::filesystem::path& p, std::error_code& ec ) noexcept;
#endif
}
} // std

View File

@ -16,7 +16,7 @@ namespace nana{ namespace paint{
public:
using graph_reference = nana::paint::graphics&;
virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp
virtual bool open(const std::experimental::filesystem::path& file) = 0;
virtual bool open(const std::filesystem::path& file) = 0;
virtual bool open(const void* data, std::size_t bytes) = 0; // reads image from memory
virtual bool alpha_channel() const = 0;
virtual bool empty() const = 0;

View File

@ -33,7 +33,7 @@ namespace nana
{
friend class graphics;
public:
using path_type = ::std::experimental::filesystem::path;
using path_type = ::std::filesystem::path;
using font_style = ::nana::detail::font_style;

View File

@ -158,7 +158,7 @@ namespace nana
: public font_interface
{
public:
using path_type = std::experimental::filesystem::path;
using path_type = std::filesystem::path;
internal_font(const path_type& ttf, const std::string& font_family, double font_size, const font_style& fs, native_font_type native_font):
ttf_(ttf),

View File

@ -28,7 +28,7 @@ namespace nana
public:
using font = font_interface;
using path_type = ::std::experimental::filesystem::path;
using path_type = ::std::filesystem::path;
static void initialize();
/// Shutdown before destruction of platform_spec

View File

@ -1,3 +1,5 @@
#include <nana/c++defines.hpp>
#if defined(NANA_POSIX) && defined(NANA_X11)
#include "theme.hpp"
#include <nana/filesystem/filesystem.hpp>
#include <algorithm>
@ -296,3 +298,4 @@ namespace nana
}
}
#endif

View File

@ -1123,11 +1123,12 @@ namespace nana { namespace experimental { namespace filesystem
} //end namespace experimental
}//end namespace nana
#if (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)))
namespace std
{
namespace filesystem
{
#if defined(NANA_FILESYSTEM_FORCE) || \
(defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)))
path absolute(const path& p)
{
if (p.empty())
@ -1236,9 +1237,26 @@ namespace std
{
return canonical(p, &err);
}
#endif
#if defined(NANA_FILESYSTEM_FORCE) || defined(NANA_MINGW)
bool exists( std::filesystem::file_status s ) noexcept
{
return s.type() != file_type::not_found;
}
bool exists( const std::filesystem::path& p )
{
return exists(status(p));
}
bool exists( const std::filesystem::path& p, std::error_code& ec ) noexcept
{
return exists(status(p, ec));
}
#endif
}//end namespace filesystem
}//end namespace std
#endif
#endif

View File

@ -19,6 +19,7 @@
#include <map>
#include <set>
#include <cstring>
#ifdef NANA_WINDOWS
# include <windows.h>

View File

@ -111,11 +111,11 @@ namespace nana{ namespace paint
return true;
}
bool open(const std::experimental::filesystem::path& filename) override
bool open(const std::filesystem::path& filename) override
{
std::ifstream ifs(filename.string(), std::ios::binary);
auto const bytes = static_cast<unsigned>(std::experimental::filesystem::file_size(filename));
auto const bytes = static_cast<unsigned>(std::filesystem::file_size(filename));
if (ifs && (bytes > static_cast<int>(sizeof(bitmap_file_header))))
{
std::unique_ptr<char[]> buffer{ new char[bytes] };

View File

@ -241,7 +241,7 @@ public:
#endif
}
bool open(const std::experimental::filesystem::path& ico_file) override
bool open(const std::filesystem::path& ico_file) override
{
std::ifstream file(ico_file.string(), std::ios::binary);
if (!file.is_open()) return false;
@ -290,7 +290,7 @@ public:
#endif
}
private:
std::experimental::filesystem::path path_;
std::filesystem::path path_;
#if defined(NANA_WINDOWS)
void* native_handle_{nullptr};
#endif

View File

@ -29,7 +29,7 @@ namespace nana{ namespace paint
:public image::image_impl_interface
{
public:
bool open(const std::experimental::filesystem::path& filename) override
bool open(const std::filesystem::path& filename) override
{
#if defined(NANA_WINDOWS)
SHFILEINFO sfi;

View File

@ -47,7 +47,7 @@ namespace nana
}
}
public:
bool open(const std::experimental::filesystem::path& jpeg_file) override
bool open(const std::filesystem::path& jpeg_file) override
{
auto fp = ::fopen(to_osmbstr(to_utf8(jpeg_file.native())).c_str(), "rb");
if(nullptr == fp) return false;

View File

@ -123,7 +123,7 @@ namespace nana
delete[] row_ptrs;
}
public:
bool open(const std::experimental::filesystem::path& png_file) override
bool open(const std::filesystem::path& png_file) override
{
auto fp = ::fopen(to_osmbstr(to_utf8(png_file.native())).c_str(), "rb");
if(nullptr == fp) return false;

View File

@ -38,7 +38,7 @@
#include "detail/image_ico_resource.hpp"
#include "detail/image_ico.hpp"
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
namespace nana
{

View File

@ -47,7 +47,7 @@ namespace nana
std::uint16_t string_offset; //from start of storage area
};
public:
using path_type = ::std::experimental::filesystem::path;
using path_type = ::std::filesystem::path;
truetype(const path_type& filename)
{