Merge branch 'qPCR4vir-dev_nana_fs' into develop
This commit is contained in:
commit
1a85a0a061
@ -56,7 +56,7 @@ matrix:
|
||||
- llvm-toolchain-precise
|
||||
|
||||
before_install:
|
||||
- git clone --depth=1 --branch=dev_nana_in_examples https://github.com/qPCR4vir/nana-demo.git nana-demo
|
||||
- git clone --depth=1 --branch=dev_nana_fs https://github.com/qPCR4vir/nana-demo.git nana-demo
|
||||
- export PATH="$HOME/bin:$PATH"
|
||||
- mkdir ~/bin
|
||||
- wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.4/cmake-3.4.0-rc3-Linux-x86_64.sh || true
|
||||
|
||||
@ -59,6 +59,7 @@
|
||||
|
||||
# define constexpr const //no support of constexpr until Visual C++ 2015 ? const ??
|
||||
# endif
|
||||
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
||||
#elif defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
|
||||
# define noexcept //no support of noexcept until GCC 4.6
|
||||
|
||||
@ -30,6 +30,9 @@
|
||||
#ifndef NANA_FILESYSTEM_HPP
|
||||
#define NANA_FILESYSTEM_HPP
|
||||
|
||||
//#undef NANA_USING_NANA_FILESYSTEM
|
||||
#if NANA_USING_NANA_FILESYSTEM
|
||||
|
||||
#include <nana/push_ignore_diagnostic>
|
||||
|
||||
#include <string>
|
||||
@ -233,18 +236,18 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
{
|
||||
public:
|
||||
directory_entry() = default;
|
||||
explicit directory_entry(const path&);
|
||||
explicit directory_entry(const ::nana::experimental::filesystem::path&);
|
||||
|
||||
//modifiers
|
||||
void assign(const path&);
|
||||
void replace_filename(const path&);
|
||||
void assign(const ::nana::experimental::filesystem::path&);
|
||||
void replace_filename(const ::nana::experimental::filesystem::path&);
|
||||
|
||||
//observers
|
||||
file_status status() const;
|
||||
operator const filesystem::path&() const;
|
||||
operator const filesystem::path&() const { return path_; };
|
||||
const filesystem::path& path() const;
|
||||
private:
|
||||
filesystem::path path_;
|
||||
::nana::experimental::filesystem::path path_;
|
||||
};
|
||||
|
||||
/// InputIterator that iterate over the sequence of directory_entry elements representing the files in a directory, not an recursive_directory_iterator
|
||||
@ -356,7 +359,6 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
bool create_directory(const path& p, const path& attributes);
|
||||
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
|
||||
|
||||
bool modified_file_time(const path& p, struct tm&); ///< extention ?
|
||||
|
||||
/// The time of last data modification of p, determined as if by the value of the POSIX
|
||||
/// stat structure member st_mtime obtained as if by POSIX stat().
|
||||
@ -364,7 +366,6 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
/// returns file_time_type::min() if an error occurs
|
||||
//file_time_type last_write_time(const path& p, error_code& ec) noexcept;
|
||||
|
||||
path path_user(); ///< extention ?
|
||||
|
||||
path current_path();
|
||||
//path current_path(error_code& ec);
|
||||
@ -414,3 +415,4 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
|
||||
#include <nana/pop_ignore_diagnostic>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -15,10 +15,16 @@
|
||||
#ifndef NANA_FILESYSTEM_EXT_HPP
|
||||
#define NANA_FILESYSTEM_EXT_HPP
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <nana/filesystem/filesystem_selector.hpp>
|
||||
|
||||
namespace nana {namespace experimental {namespace filesystem {namespace ext {
|
||||
namespace nana
|
||||
{
|
||||
namespace filesystem_ext
|
||||
{
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
constexpr auto def_root = "C:";
|
||||
constexpr auto def_rootstr = "C:\\";
|
||||
@ -29,14 +35,13 @@ namespace nana {namespace experimental {namespace filesystem {namespace ext {
|
||||
constexpr auto def_rootname = "Root/";
|
||||
#endif
|
||||
|
||||
// nana::experimental::filesystem::path_user());
|
||||
std::experimental::filesystem::path path_user(); ///< extention ?
|
||||
|
||||
inline bool is_directory(const std::experimental::filesystem::directory_entry& dir) noexcept
|
||||
{
|
||||
return is_directory(dir.status());
|
||||
}
|
||||
|
||||
|
||||
//template<class DI> // DI = directory_iterator from std, boost, or nana : return directory_entry
|
||||
class directory_only_iterator : public std::experimental::filesystem::directory_iterator
|
||||
{
|
||||
@ -78,7 +83,6 @@ inline directory_only_iterator end(const directory_only_iterator&) noexcept
|
||||
return{};
|
||||
}
|
||||
|
||||
|
||||
//template<class DI> // DI = directory_iterator from std, boost, or nana : value_type directory_entry
|
||||
class regular_file_only_iterator : public std::experimental::filesystem::directory_iterator
|
||||
{
|
||||
@ -115,53 +119,13 @@ inline regular_file_only_iterator end(const regular_file_only_iterator&) noexcep
|
||||
return{};
|
||||
}
|
||||
|
||||
inline std::string pretty_file_size(const std::experimental::filesystem::path& path) // todo: move to .cpp
|
||||
{
|
||||
try {
|
||||
auto bytes = std::experimental::filesystem::file_size ( path );
|
||||
const char * ustr[] = { " KB", " MB", " GB", " TB" };
|
||||
std::stringstream ss;
|
||||
if (bytes < 1024)
|
||||
ss << bytes << " Bytes";
|
||||
else
|
||||
{
|
||||
double cap = bytes / 1024.0;
|
||||
std::size_t uid = 0;
|
||||
while ((cap >= 1024.0) && (uid < sizeof(ustr) / sizeof(char *)))
|
||||
{
|
||||
cap /= 1024.0;
|
||||
++uid;
|
||||
}
|
||||
ss << cap;
|
||||
auto s = ss.str();
|
||||
auto pos = s.find('.');
|
||||
if (pos != s.npos)
|
||||
{
|
||||
if (pos + 2 < s.size())
|
||||
s.erase(pos + 2);
|
||||
}
|
||||
return s + ustr[uid];
|
||||
}
|
||||
std::string pretty_file_size(const std::experimental::filesystem::path& path);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
catch (...) {}
|
||||
return {};
|
||||
}
|
||||
std::string pretty_file_date(const std::experimental::filesystem::path& path);
|
||||
|
||||
inline std::string pretty_file_date(const std::experimental::filesystem::path& path) // todo: move to .cpp
|
||||
{
|
||||
try {
|
||||
auto ftime = std::experimental::filesystem::last_write_time(path);
|
||||
std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
|
||||
std::stringstream tm;
|
||||
tm << std::put_time(std::localtime(&cftime), "%Y-%m-%d, %H:%M:%S");
|
||||
return tm.str();
|
||||
}
|
||||
catch (...) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
bool modified_file_time(const std::experimental::filesystem::path& p, struct tm&); ///< extention ?
|
||||
|
||||
} // filesystem_ext
|
||||
} // nana
|
||||
|
||||
}}}}
|
||||
#endif //NANA_FILESYSTEM_EXT_HPP
|
||||
|
||||
@ -35,6 +35,8 @@
|
||||
|
||||
#if (defined(NANA_FILESYSTEM_FORCE) || ( (defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(BOOST_FILESYSTEM_AVAILABLE)) && !(defined(BOOST_FILESYSTEM_FORCE) || defined(STD_FILESYSTEM_FORCE)) ) )
|
||||
|
||||
#undef NANA_USING_NANA_FILESYSTEM
|
||||
#define NANA_USING_NANA_FILESYSTEM true
|
||||
# include <nana/filesystem/filesystem.hpp>
|
||||
|
||||
namespace std {
|
||||
@ -46,14 +48,14 @@ namespace std {
|
||||
# else
|
||||
using namespace nana::experimental::filesystem::v1;
|
||||
# endif
|
||||
#undef NANA_USING_NANA_FILESYSTEM
|
||||
#define NANA_USING_NANA_FILESYSTEM true
|
||||
} // filesystem
|
||||
} // experimental
|
||||
} // std
|
||||
|
||||
#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) ))
|
||||
|
||||
#undef NANA_USING_BOOST_FILESYSTEM
|
||||
#define NANA_USING_BOOST_FILESYSTEM true
|
||||
# include <boost/filesystem.hpp>
|
||||
|
||||
// add boost::filesystem into std::experimental::filesystem
|
||||
@ -61,17 +63,15 @@ namespace std {
|
||||
namespace experimental {
|
||||
namespace filesystem {
|
||||
using namespace boost::filesystem;
|
||||
#undef NANA_USING_BOOST_FILESYSTEM
|
||||
#define NANA_USING_BOOST_FILESYSTEM true
|
||||
} // filesystem
|
||||
} // experimental
|
||||
} // std
|
||||
|
||||
#else
|
||||
|
||||
# include <experimental/filesystem>
|
||||
#undef NANA_USING_STD_FILESYSTEM
|
||||
#define NANA_USING_STD_FILESYSTEM true
|
||||
# include <experimental/filesystem>
|
||||
#endif
|
||||
|
||||
#ifndef __cpp_lib_experimental_filesystem
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/**
|
||||
* Filebox
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
@ -7,7 +7,9 @@
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/filebox.hpp
|
||||
* @file nana/gui/filebox.hpp
|
||||
* @author Jinhao
|
||||
* @brief a dialog to chose file(s), implemented "native" in windows but using nana for X11
|
||||
*/
|
||||
|
||||
#ifndef NANA_GUI_FILEBOX_HPP
|
||||
@ -37,18 +39,20 @@ namespace nana
|
||||
/// Change owner window
|
||||
void owner(window);
|
||||
|
||||
/// specify a title for the dialog
|
||||
/// Set a new title for the dialog
|
||||
/// @param string a text for title
|
||||
/// @return old title.
|
||||
::std::string title( ::std::string new_title); ///< . Set a new title for the dialog and \return the old title
|
||||
/// @return the old title.
|
||||
::std::string title( ::std::string new_title);
|
||||
|
||||
/** @brief specify a suggestion directory
|
||||
* @param string a path of initial directory
|
||||
/** @brief Suggest initial path used to locate a directory when the filebox starts.
|
||||
* @param string initial_directory a path of initial directory
|
||||
* @note the behavior of init_path is different between Win7 and Win2K/XP/Vista, but its behavior under Linux is conformed with Win7.
|
||||
*/
|
||||
filebox& init_path(const ::std::string&); ///< Suggested init path used to locate a directory when the filebox starts.
|
||||
filebox& init_path(const ::std::string& initial_directory);
|
||||
|
||||
filebox& init_file(const ::std::string&); ///< Init file, if it contains a path, the init path is replaced by the path of init file.
|
||||
/// \brief Add a filetype filter.
|
||||
|
||||
/// \brief Add a filetype filter.
|
||||
/// To specify multiple filter in a single description, use a semicolon to separate the patterns(for example,"*.TXT;*.DOC;*.BAK").
|
||||
filebox& add_filter(const ::std::string& description, ///< for example. "Text File"
|
||||
const ::std::string& filetype ///< filter pattern(for example, "*.TXT")
|
||||
@ -68,8 +72,7 @@ namespace nana
|
||||
/// Display the filebox dialog
|
||||
bool show() const;
|
||||
|
||||
/// Display the filebox dialog
|
||||
/// A function object method alternative to show()
|
||||
/// a function object method alternative to show() to display the filebox dialog,
|
||||
bool operator()() const
|
||||
{
|
||||
return show();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define NANA_PAINT_DETAIL_IMAGE_IMPL_INTERFACE_HPP
|
||||
|
||||
#include "../image.hpp"
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
#include <nana/filesystem/filesystem_ext.hpp>
|
||||
|
||||
namespace nana{ namespace paint{
|
||||
|
||||
@ -16,7 +16,7 @@ namespace nana{ namespace paint{
|
||||
public:
|
||||
typedef nana::paint::graphics& graph_reference;
|
||||
virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp
|
||||
virtual bool open(const nana::experimental::filesystem::path& file) = 0;
|
||||
virtual bool open(const std::experimental::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;
|
||||
|
||||
@ -13,10 +13,11 @@
|
||||
#ifndef NANA_PAINT_GRAPHICS_HPP
|
||||
#define NANA_PAINT_GRAPHICS_HPP
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "../basic_types.hpp"
|
||||
#include "../gui/basis.hpp"
|
||||
#include "pixel_buffer.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
* provide some interface for file managment
|
||||
*/
|
||||
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
#include <nana/filesystem/filesystem_ext.hpp>
|
||||
#include <vector>
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
@ -36,6 +36,121 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace filesystem_ext
|
||||
{
|
||||
|
||||
fs::path path_user()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
wchar_t pstr[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, pstr)))
|
||||
return pstr;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
const char * pstr = ::getenv("HOME");
|
||||
if (pstr)
|
||||
return pstr;
|
||||
#endif
|
||||
return fs::path();
|
||||
}
|
||||
|
||||
std::string pretty_file_size(const fs::path& path)
|
||||
{
|
||||
try {
|
||||
auto bytes = fs::file_size(path);
|
||||
const char * ustr[] = { " KB", " MB", " GB", " TB" };
|
||||
std::stringstream ss;
|
||||
if (bytes < 1024)
|
||||
ss << bytes << " Bytes";
|
||||
else
|
||||
{
|
||||
double cap = bytes / 1024.0;
|
||||
std::size_t uid = 0;
|
||||
while ((cap >= 1024.0) && (uid < sizeof(ustr) / sizeof(char *)))
|
||||
{
|
||||
cap /= 1024.0;
|
||||
++uid;
|
||||
}
|
||||
ss << cap;
|
||||
auto s = ss.str();
|
||||
auto pos = s.find('.');
|
||||
if (pos != s.npos)
|
||||
{
|
||||
if (pos + 2 < s.size())
|
||||
s.erase(pos + 2);
|
||||
}
|
||||
return s + ustr[uid];
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
catch (...) {}
|
||||
return{};
|
||||
}
|
||||
|
||||
std::string pretty_file_date(const fs::path& path) // todo: move to .cpp
|
||||
{
|
||||
try {
|
||||
auto ftime = fs::last_write_time(path);
|
||||
|
||||
// crash: VS2015 will not read the time for some files (for example: C:/hiberfil.sys)
|
||||
// and will return file_time_type(-1) without throwing
|
||||
// https://msdn.microsoft.com/en-us/library/dn823784.aspx
|
||||
|
||||
if (ftime == ((fs::file_time_type::min)())) return{};
|
||||
|
||||
std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
|
||||
std::stringstream tm;
|
||||
tm << std::put_time(std::localtime(&cftime), "%Y-%m-%d, %H:%M:%S");
|
||||
return tm.str();
|
||||
}
|
||||
catch (...) {
|
||||
return{};
|
||||
}
|
||||
}
|
||||
|
||||
bool modified_file_time(const fs::path& p, struct tm& t)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||
if (::GetFileAttributesEx(p.c_str(), GetFileExInfoStandard, &attr))
|
||||
{
|
||||
FILETIME local_file_time;
|
||||
if (::FileTimeToLocalFileTime(&attr.ftLastWriteTime, &local_file_time))
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
::FileTimeToSystemTime(&local_file_time, &st);
|
||||
t.tm_year = st.wYear - 1900;
|
||||
t.tm_mon = st.wMonth - 1;
|
||||
t.tm_mday = st.wDay;
|
||||
t.tm_wday = st.wDayOfWeek - 1;
|
||||
t.tm_yday = nana::date::day_in_year(st.wYear, st.wMonth, st.wDay);
|
||||
|
||||
t.tm_hour = st.wHour;
|
||||
t.tm_min = st.wMinute;
|
||||
t.tm_sec = st.wSecond;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#elif defined(NANA_POSIX)
|
||||
struct stat attr;
|
||||
if (0 == ::stat(p.c_str(), &attr))
|
||||
{
|
||||
t = *(::localtime(&attr.st_ctime));
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if NANA_USING_NANA_FILESYSTEM
|
||||
|
||||
namespace nana_fs = nana::experimental::filesystem;
|
||||
|
||||
namespace nana { namespace experimental { namespace filesystem
|
||||
{
|
||||
@ -143,7 +258,7 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
|
||||
path path::parent_path() const
|
||||
{
|
||||
return{filesystem::parent_path(pathstr_)};
|
||||
return{nana_fs::parent_path(pathstr_)};
|
||||
}
|
||||
|
||||
file_type path::what() const
|
||||
@ -342,17 +457,17 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
}
|
||||
|
||||
//class directory_entry
|
||||
directory_entry::directory_entry(const filesystem::path& p)
|
||||
directory_entry::directory_entry(const nana_fs::path& p)
|
||||
:path_{ p }
|
||||
{}
|
||||
|
||||
//modifiers
|
||||
void directory_entry::assign(const filesystem::path& p)
|
||||
void directory_entry::assign(const nana_fs::path& p)
|
||||
{
|
||||
path_ = p;
|
||||
}
|
||||
|
||||
void directory_entry::replace_filename(const filesystem::path& p)
|
||||
void directory_entry::replace_filename(const nana_fs::path& p)
|
||||
{
|
||||
path_ = path_.parent_path() / p;
|
||||
}
|
||||
@ -360,15 +475,15 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
//observers
|
||||
file_status directory_entry::status() const
|
||||
{
|
||||
return filesystem::status(path_);
|
||||
return nana_fs::status(path_);
|
||||
}
|
||||
|
||||
directory_entry::operator const filesystem::path&() const
|
||||
{
|
||||
return path_;
|
||||
}
|
||||
//directory_entry::operator const nana_fs::path&() const
|
||||
//{
|
||||
// return path_;
|
||||
//}
|
||||
|
||||
const path& directory_entry::path() const
|
||||
const nana_fs::path& directory_entry::path() const
|
||||
{
|
||||
return path_;
|
||||
}
|
||||
@ -751,44 +866,11 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
#endif
|
||||
}
|
||||
|
||||
bool modified_file_time(const path& p, struct tm& t)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||
if (::GetFileAttributesEx(p.c_str(), GetFileExInfoStandard, &attr))
|
||||
{
|
||||
FILETIME local_file_time;
|
||||
if (::FileTimeToLocalFileTime(&attr.ftLastWriteTime, &local_file_time))
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
::FileTimeToSystemTime(&local_file_time, &st);
|
||||
t.tm_year = st.wYear - 1900;
|
||||
t.tm_mon = st.wMonth - 1;
|
||||
t.tm_mday = st.wDay;
|
||||
t.tm_wday = st.wDayOfWeek - 1;
|
||||
t.tm_yday = nana::date::day_in_year(st.wYear, st.wMonth, st.wDay);
|
||||
|
||||
t.tm_hour = st.wHour;
|
||||
t.tm_min = st.wMinute;
|
||||
t.tm_sec = st.wSecond;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#elif defined(NANA_POSIX)
|
||||
struct stat attr;
|
||||
if (0 == ::stat(p.c_str(), &attr))
|
||||
{
|
||||
t = *(::localtime(&attr.st_ctime));
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
file_time_type last_write_time(const path& p)
|
||||
{
|
||||
struct tm t;
|
||||
modified_file_time(p, t);
|
||||
nana::filesystem_ext::modified_file_time(p, t);
|
||||
std::chrono::system_clock::time_point dateTime =std::chrono::system_clock::from_time_t( mktime(&t) );
|
||||
return dateTime;
|
||||
}
|
||||
@ -821,20 +903,6 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
return detail::rm_file(p);
|
||||
}
|
||||
|
||||
path path_user()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
wchar_t pstr[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, pstr)))
|
||||
return pstr;
|
||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
const char * pstr = ::getenv("HOME");
|
||||
if (pstr)
|
||||
return pstr;
|
||||
#endif
|
||||
return path();
|
||||
}
|
||||
|
||||
path current_path()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
@ -887,3 +955,5 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
}//end namespace filesystem
|
||||
} //end namespace experimental
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#include <nana/gui.hpp>
|
||||
#include <nana/gui/filebox.hpp>
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
#include <nana/filesystem/filesystem_ext.hpp>
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
@ -24,12 +24,15 @@
|
||||
#include <nana/gui/widgets/textbox.hpp>
|
||||
#include <nana/gui/widgets/treebox.hpp>
|
||||
#include <nana/gui/widgets/combox.hpp>
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
#include <nana/gui/place.hpp>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
namespace fs_ext = nana::filesystem_ext;
|
||||
|
||||
|
||||
namespace nana
|
||||
{
|
||||
#if defined(NANA_POSIX)
|
||||
@ -54,7 +57,7 @@ namespace nana
|
||||
friend listbox::oresolver& operator<<(listbox::oresolver& ores, const item_fs& item)
|
||||
{
|
||||
std::wstringstream tm;
|
||||
tm<<(item.modified_time.tm_year + 1900)<<'-';
|
||||
tm<<(item.modified_time.tm_year + 1900)<<'-'; /// \todo : use nana::filesystem_ext:: pretty_file_date
|
||||
_m_add(tm, item.modified_time.tm_mon + 1)<<'-';
|
||||
_m_add(tm, item.modified_time.tm_mday)<<' ';
|
||||
|
||||
@ -87,7 +90,7 @@ namespace nana
|
||||
return ss;
|
||||
}
|
||||
|
||||
static std::string _m_trans(std::size_t bytes)
|
||||
static std::string _m_trans(std::size_t bytes) /// \todo : use nana::filesystem_ext::pretty_file_size
|
||||
{
|
||||
const char * ustr[] = {" KB", " MB", " GB", " TB"};
|
||||
std::stringstream ss;
|
||||
@ -142,13 +145,13 @@ namespace nana
|
||||
auto path = path_.caption();
|
||||
auto root = path.substr(0, path.find('/'));
|
||||
if(root == "HOME")
|
||||
path.replace(0, 4, nana::experimental::filesystem::path_user().native());
|
||||
path.replace(0, 4, fs_ext::path_user().native());
|
||||
else if(root == "FILESYSTEM")
|
||||
path.erase(0, 10);
|
||||
else
|
||||
throw std::runtime_error("Nana.GUI.Filebox: Wrong categorize path");
|
||||
|
||||
if(path.size() == 0) path = "/";
|
||||
if(path.size() == 0) path = "/"; /// \todo : use nana::filesystem_ext::def_rootstr?
|
||||
_m_load_cat_path(path);
|
||||
});
|
||||
|
||||
@ -344,7 +347,7 @@ namespace nana
|
||||
else
|
||||
dir = saved_selected_path;
|
||||
|
||||
_m_load_cat_path(dir.size() ? dir : nana::experimental::filesystem::path_user().native());
|
||||
_m_load_cat_path(dir.size() ? dir : fs_ext::path_user().native());
|
||||
|
||||
tb_file_.caption(file_with_path_removed);
|
||||
}
|
||||
@ -427,10 +430,8 @@ namespace nana
|
||||
nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem");
|
||||
nodes_.filesystem.value(kind::filesystem);
|
||||
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
|
||||
std::vector<std::string> paths;
|
||||
paths.emplace_back(fs::path_user().native());
|
||||
paths.emplace_back(fs_ext::path_user().native());
|
||||
paths.emplace_back("/");
|
||||
|
||||
fs::directory_iterator end;
|
||||
@ -474,7 +475,7 @@ namespace nana
|
||||
{
|
||||
auto begstr = path.substr(0, pos);
|
||||
if(begstr == "FS.HOME")
|
||||
path.replace(0, 7, nana::experimental::filesystem::path_user().native());
|
||||
path.replace(0, 7, fs_ext::path_user().native());
|
||||
else
|
||||
path.erase(0, pos);
|
||||
return begstr;
|
||||
@ -490,8 +491,6 @@ namespace nana
|
||||
|
||||
file_container_.clear();
|
||||
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
|
||||
fs::directory_iterator end;
|
||||
for(fs::directory_iterator i(path); i != end; ++i)
|
||||
{
|
||||
@ -508,13 +507,13 @@ namespace nana
|
||||
{
|
||||
m.bytes = fs::file_size(path + m.name);
|
||||
m.directory = fs::is_directory(fattr);
|
||||
::nana::experimental::filesystem::modified_file_time(path + m.name, m.modified_time);
|
||||
fs_ext::modified_file_time(path + m.name, m.modified_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
m.bytes = 0;
|
||||
m.directory = fs::is_directory(*i);
|
||||
::nana::experimental::filesystem::modified_file_time(path + i->path().filename().native(), m.modified_time);
|
||||
fs_ext::modified_file_time(path + i->path().filename().native(), m.modified_time);
|
||||
}
|
||||
|
||||
file_container_.push_back(m);
|
||||
@ -534,7 +533,7 @@ namespace nana
|
||||
while(!beg_node.empty() && (beg_node != nodes_.home) && (beg_node != nodes_.filesystem))
|
||||
beg_node = beg_node.owner();
|
||||
|
||||
auto head = nana::experimental::filesystem::path_user().native();
|
||||
auto head = fs_ext::path_user().native();
|
||||
if(path.size() >= head.size() && (path.substr(0, head.size()) == head))
|
||||
{//This is HOME
|
||||
path_.caption("HOME");
|
||||
@ -552,7 +551,6 @@ namespace nana
|
||||
if(head.size() == 0 || head[head.size() - 1] != '/')
|
||||
head += '/';
|
||||
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
|
||||
fs::directory_iterator end;
|
||||
for(fs::directory_iterator i(head); i != end; ++i)
|
||||
@ -649,20 +647,20 @@ namespace nana
|
||||
return;
|
||||
}
|
||||
|
||||
using file_type = nana::experimental::filesystem::file_type;
|
||||
using file_type = fs::file_type;
|
||||
|
||||
experimental::filesystem::path fspath(fb_.addr_.filesystem + path);
|
||||
fs::path fspath(fb_.addr_.filesystem + path);
|
||||
|
||||
auto fs = experimental::filesystem::status(fspath);
|
||||
auto fst = fs::status(fspath);
|
||||
|
||||
if(fs.type() != file_type::not_found && fs.type() != file_type::none)
|
||||
if(fst.type() != file_type::not_found && fst.type() != file_type::none)
|
||||
{
|
||||
mb<<L"The folder is existing, please rename it.";
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
|
||||
if(false == experimental::filesystem::create_directory(fspath))
|
||||
if(false == fs::create_directory(fspath))
|
||||
{
|
||||
mb<<L"Failed to create the folder, please rename it.";
|
||||
mb();
|
||||
@ -756,7 +754,6 @@ namespace nana
|
||||
|
||||
bool good = true;
|
||||
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
auto fattr = fs::status(tar);
|
||||
if(fattr.type() == fs::file_type::not_found)
|
||||
{
|
||||
@ -809,8 +806,6 @@ namespace nana
|
||||
auto path = tree_.make_key_path(node, "/") + "/";
|
||||
_m_resolute_path(path);
|
||||
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
|
||||
fs::directory_iterator end;
|
||||
for (fs::directory_iterator i{path}; i != end; ++i)
|
||||
{
|
||||
@ -952,7 +947,6 @@ namespace nana
|
||||
}
|
||||
else
|
||||
{
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
if (fs::is_directory(ipstr))
|
||||
impl_->path = ipstr;
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
#ifndef NANA_PAINT_DETAIL_IMAGE_BMP_HPP
|
||||
#define NANA_PAINT_DETAIL_IMAGE_BMP_HPP
|
||||
|
||||
#include "image_pixbuf.hpp"
|
||||
#include <memory>
|
||||
#include "image_pixbuf.hpp"
|
||||
|
||||
namespace nana{ namespace paint
|
||||
{
|
||||
@ -309,7 +309,7 @@ namespace nana{ namespace paint
|
||||
return true;
|
||||
}
|
||||
|
||||
bool open(const nana::experimental::filesystem::path& filename) override
|
||||
bool open(const std::experimental::filesystem::path& filename) override
|
||||
{
|
||||
std::ifstream ifs(filename.string(), std::ios::binary);
|
||||
if(ifs)
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#ifndef NANA_PAINT_DETAIL_IMAGE_ICO_HPP
|
||||
#define NANA_PAINT_DETAIL_IMAGE_ICO_HPP
|
||||
|
||||
#include <nana/filesystem/filesystem_ext.hpp>
|
||||
#include <nana/paint/detail/image_impl_interface.hpp>
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
|
||||
namespace nana{ namespace paint
|
||||
{
|
||||
@ -24,7 +24,7 @@ namespace nana{ namespace paint
|
||||
image_ico(bool is_ico);
|
||||
|
||||
|
||||
bool open(const ::nana::experimental::filesystem::path& filename) override;
|
||||
bool open(const std::experimental::filesystem::path& filename) override;
|
||||
bool open(const void* data, std::size_t bytes) override;
|
||||
bool alpha_channel() const override;
|
||||
bool empty() const override;
|
||||
|
||||
@ -47,7 +47,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
public:
|
||||
bool open(const experimental::filesystem::path& jpeg_file) override
|
||||
bool open(const std::experimental::filesystem::path& jpeg_file) override
|
||||
{
|
||||
auto fp = ::fopen(to_osmbstr(to_utf8(jpeg_file.native())).c_str(), "rb");
|
||||
if(nullptr == fp) return false;
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include <nana/paint/detail/image_impl_interface.hpp>
|
||||
#include <nana/paint/pixel_buffer.hpp>
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
#include <nana/filesystem/filesystem_ext.hpp>
|
||||
|
||||
#if defined(NANA_ENABLE_JPEG)
|
||||
#include "detail/image_jpeg.hpp"
|
||||
@ -36,6 +36,8 @@
|
||||
|
||||
#include "image_accessor.hpp"
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace paint
|
||||
@ -60,7 +62,7 @@ namespace paint
|
||||
//class image_ico
|
||||
image_ico::image_ico(bool is_ico): is_ico_(is_ico){}
|
||||
|
||||
bool image_ico::open(const nana::experimental::filesystem::path& file)
|
||||
bool image_ico::open(const fs::path& file)
|
||||
{
|
||||
close();
|
||||
#if defined(NANA_WINDOWS)
|
||||
@ -231,7 +233,7 @@ namespace paint
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::shared_ptr<image::image_impl_interface> create_image(const ::nana::experimental::filesystem::path & p)
|
||||
std::shared_ptr<image::image_impl_interface> create_image(const fs::path & p)
|
||||
{
|
||||
std::shared_ptr<image::image_impl_interface> ptr;
|
||||
|
||||
@ -314,14 +316,14 @@ namespace paint
|
||||
|
||||
bool image::open(const ::std::string& file)
|
||||
{
|
||||
::nana::experimental::filesystem::path path(file);
|
||||
fs::path path(file);
|
||||
image_ptr_ = create_image(path);
|
||||
return (image_ptr_ ? image_ptr_->open(path) : false);
|
||||
}
|
||||
|
||||
bool image::open(const std::wstring& file)
|
||||
{
|
||||
::nana::experimental::filesystem::path path(file);
|
||||
fs::path path(file);
|
||||
image_ptr_ = create_image(path);
|
||||
return (image_ptr_ ? image_ptr_->open(path) : false);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user