update filesystem and remove fs_utility

This commit is contained in:
Jinhao
2016-01-20 01:06:16 +08:00
parent 8d2ec2fbd1
commit ece696c3b5
18 changed files with 403 additions and 472 deletions

View File

@@ -282,6 +282,7 @@ namespace filesystem
file_status status(const path& p);
file_status status(const path& p, std::error_code&);
std::uintmax_t file_size(const path& p);
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
@@ -315,7 +316,8 @@ 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 std::wstring& file, struct tm&);
bool modified_file_time(const path& p, struct tm&);
path path_user();
path current_path();
@@ -324,14 +326,13 @@ namespace filesystem
//void current_path(const path& p, error_code& ec) noexcept;
//bool remove(const path& p);
//bool remove(const path& p, error_code& ec) noexcept;
bool rmfile(const path& p);
bool remove(const path& p);
bool remove(const path& p, std::error_code& ec); // noexcept;
//uintmax_t remove_all(const path& p);
//uintmax_t remove_all(const path& p, error_code& ec) noexcept;
bool rmdir(const path& p, bool fails_if_not_empty);
//bool rmdir(const path& p, bool fails_if_not_empty); //deprecated
template<typename CharType>
std::basic_string<CharType> parent_path(const std::basic_string<CharType>& path)

View File

@@ -1,35 +0,0 @@
#ifndef NANA_FILESYSTEM_FS_UTILITY_HPP
#define NANA_FILESYSTEM_FS_UTILITY_HPP
#include <nana/deploy.hpp>
#include <ctime>
namespace nana
{
namespace filesystem
{
struct error
{
enum
{
none = 0
};
};
struct attribute
{
long long bytes;
bool is_directory;
tm modified;
};
bool modified_file_time(const ::std::string& file, struct tm&);
std::string path_user();
bool rmfile(const char* file_utf8);
}//end namespace filesystem
}//end namespace nana
#endif

View File

@@ -1,7 +1,7 @@
/**
* Definition of General Events
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -111,7 +111,7 @@ namespace nana
evt_->deleted_flags_ = false;
for (auto i = evt_->dockers_->begin(); i != evt_->dockers_->end();)
{
if (i->get()->flag_deleted)
if (static_cast<docker*>(i->get())->flag_deleted)
i = evt_->dockers_->erase(i);
else
++i;
@@ -128,11 +128,11 @@ namespace nana
{
internal_scope_guard lock;
if (nullptr == dockers_)
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
using prototype = typename std::remove_reference<Function>::type;
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
auto evt = reinterpret_cast<event_handle>(dck.get());
dockers_->emplace(dockers_->begin(), std::move(dck));
detail::events_operation_register(evt);
return evt;
@@ -151,11 +151,11 @@ namespace nana
{
internal_scope_guard lock;
if (nullptr == dockers_)
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
using prototype = typename std::remove_reference<Function>::type;
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
auto evt = reinterpret_cast<event_handle>(dck.get());
dockers_->emplace_back(std::move(dck));
detail::events_operation_register(evt);
return evt;
@@ -174,11 +174,11 @@ namespace nana
{
internal_scope_guard lock;
if (nullptr == dockers_)
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
using prototype = typename std::remove_reference<Function>::type;
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), true));
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), true));
auto evt = reinterpret_cast<event_handle>(dck.get());
if (in_front)
dockers_->emplace(dockers_->begin(), std::move(dck));
else
@@ -208,7 +208,7 @@ namespace nana
//Traverses with position can avaid crash error which caused by a iterator which becomes invalid.
for (std::size_t pos = 0; pos < dockers_len; ++pos)
{
auto docker_ptr = dockers[pos].get();
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
if (docker_ptr->flag_deleted)
continue;
@@ -217,7 +217,7 @@ namespace nana
{
for (++pos; pos < dockers_len; ++pos)
{
auto docker_ptr = dockers[pos].get();
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
if (!docker_ptr->unignorable || docker_ptr->flag_deleted)
continue;
@@ -247,7 +247,7 @@ namespace nana
//Checks whether this event is working now.
if (emitting_count_ > 1)
{
i->get()->flag_deleted = true;
static_cast<docker*>(i->get())->flag_deleted = true;
deleted_flags_ = true;
}
else
@@ -416,7 +416,7 @@ namespace nana
private:
unsigned emitting_count_{ 0 };
bool deleted_flags_{ false };
std::unique_ptr<std::vector<std::unique_ptr<docker>>> dockers_;
std::unique_ptr<std::vector<std::unique_ptr<detail::docker_interface>>> dockers_;
};
struct arg_mouse
@@ -528,7 +528,7 @@ namespace nana
/// provides some fundamental events that every widget owns.
struct general_events
{
virtual ~general_events(){}
virtual ~general_events() = default;
basic_event<arg_mouse> mouse_enter; ///< the cursor enters the window
basic_event<arg_mouse> mouse_move; ///< the cursor moves on the window
basic_event<arg_mouse> mouse_leave; ///< the cursor leaves the window

View File

@@ -1,7 +1,7 @@
/**
* A CheckBox Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,10 +17,30 @@
#include <memory>
namespace nana {
//forward-declaration
class checkbox;
struct arg_checkbox
: public event_arg
{
checkbox * const widget;
arg_checkbox(checkbox* wdg)
: widget(wdg)
{}
};
namespace drawerbase
{
namespace checkbox
{
struct events_type
: public general_events
{
basic_event<arg_checkbox> checked;
};
class drawer
: public drawer_trigger
{
@@ -51,7 +71,7 @@ namespace drawerbase
class checkbox
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer>
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer, drawerbase::checkbox::events_type>
{
public:
checkbox();
@@ -81,6 +101,7 @@ namespace drawerbase
checkbox * uiobj;
event_handle eh_checked;
event_handle eh_destroy;
event_handle eh_keyboard;
};
public:
~radio_group();

View File

@@ -2,6 +2,7 @@
#define NANA_PAINT_DETAIL_IMAGE_IMPL_INTERFACE_HPP
#include "../image.hpp"
#include <nana/filesystem/filesystem.hpp>
namespace nana{ namespace paint{

View File

@@ -1,7 +1,7 @@
/*
* Paint Image Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -16,8 +16,6 @@
#include "graphics.hpp"
#include <nana/filesystem/filesystem.hpp>
namespace nana
{
namespace paint
@@ -33,18 +31,14 @@ namespace paint
image();
image(const image&);
image(image&&);
image(const ::nana::experimental::filesystem::path& file);
template<typename Source>
image(const Source& source)
{
open(source);
}
explicit image(const ::std::string& file);
explicit image(const ::std::wstring& file);
~image();
image& operator=(const image& rhs);
image& operator=(image&&);
bool open(const ::nana::experimental::filesystem::path& file);
bool open(const ::std::string& file);
bool open(const ::std::wstring& file);
/// Opens an icon from a specified buffer
bool open_icon(const void* data, std::size_t bytes);