using explicit namespaces
This commit is contained in:
parent
2f86b26075
commit
3b6718d67f
@ -241,8 +241,8 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
|
||||
//observers
|
||||
file_status status() const;
|
||||
operator const filesystem::path&() const;
|
||||
const filesystem::path& path() const;
|
||||
operator const path&() const { return path_; };
|
||||
const path& path() const;
|
||||
private:
|
||||
filesystem::path path_;
|
||||
};
|
||||
|
||||
@ -18,7 +18,11 @@
|
||||
#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:\\";
|
||||
@ -153,6 +157,13 @@ inline std::string pretty_file_date(const std::experimental::filesystem::path& p
|
||||
{
|
||||
try {
|
||||
auto ftime = std::experimental::filesystem::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 == ((std::experimental::filesystem::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");
|
||||
@ -163,5 +174,7 @@ inline std::string pretty_file_date(const std::experimental::filesystem::path& p
|
||||
}
|
||||
}
|
||||
|
||||
}}}}
|
||||
} // filesystem_ext
|
||||
} // nana
|
||||
|
||||
#endif //NANA_FILESYSTEM_EXT_HPP
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
namespace nana_fs = nana::experimental::filesystem;
|
||||
|
||||
namespace nana { namespace experimental { namespace filesystem
|
||||
{
|
||||
@ -143,7 +144,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 +343,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,13 +361,13 @@ 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
|
||||
{
|
||||
|
||||
@ -30,6 +30,8 @@
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
namespace fs = nana::experimental::filesystem;
|
||||
|
||||
namespace nana
|
||||
{
|
||||
#if defined(NANA_POSIX)
|
||||
@ -142,7 +144,7 @@ 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::path_user().native());
|
||||
else if(root == "FILESYSTEM")
|
||||
path.erase(0, 10);
|
||||
else
|
||||
@ -344,7 +346,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::path_user().native());
|
||||
|
||||
tb_file_.caption(file_with_path_removed);
|
||||
}
|
||||
@ -427,8 +429,6 @@ 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("/");
|
||||
@ -474,7 +474,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::path_user().native());
|
||||
else
|
||||
path.erase(0, pos);
|
||||
return begstr;
|
||||
@ -490,8 +490,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 +506,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::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::modified_file_time(path + i->path().filename().native(), m.modified_time);
|
||||
}
|
||||
|
||||
file_container_.push_back(m);
|
||||
@ -530,11 +528,13 @@ namespace nana
|
||||
if((path.size() == 0) || (path[path.size() - 1] != '/'))
|
||||
path += '/';
|
||||
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
|
||||
auto beg_node = tree_.selected();
|
||||
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::path_user().native();
|
||||
if(path.size() >= head.size() && (path.substr(0, head.size()) == head))
|
||||
{//This is HOME
|
||||
path_.caption("HOME");
|
||||
@ -552,7 +552,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 +648,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 +755,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 +807,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 +948,6 @@ namespace nana
|
||||
}
|
||||
else
|
||||
{
|
||||
namespace fs = ::nana::experimental::filesystem;
|
||||
if (fs::is_directory(ipstr))
|
||||
impl_->path = ipstr;
|
||||
}
|
||||
|
||||
@ -36,6 +36,8 @@
|
||||
|
||||
#include "image_accessor.hpp"
|
||||
|
||||
namespace fs = nana::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