Merge branch 'qPCR4vir-hotfix-1.3' into hotfix-1.3
This commit is contained in:
commit
268a608851
@ -20,6 +20,7 @@ matrix:
|
||||
- alsa-oss
|
||||
- libx11-dev
|
||||
- libxft-dev
|
||||
- libboost-filesystem-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- env: CXX=g++-4.9 CC=gcc-4.9
|
||||
@ -55,7 +56,7 @@ matrix:
|
||||
- llvm-toolchain-precise
|
||||
|
||||
before_install:
|
||||
- git clone --depth=50 --branch=dev_dir_it https://github.com/qPCR4vir/nana-demo.git nana-demo
|
||||
- git clone --depth=50 --branch=dev_nana_in_examples 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
|
||||
@ -69,6 +70,6 @@ before_script :
|
||||
- cd bld
|
||||
|
||||
script:
|
||||
- cmake -G"Unix Makefiles" .. -DENABLE_JPEG=ON -DENABLE_PNG=OFF -DBUILD_NANA_DEMOS=ON -DENABLE_AUDIO=OFF
|
||||
- cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=ON
|
||||
|
||||
- make
|
||||
- make
|
||||
147
CMakeLists.txt
147
CMakeLists.txt
@ -11,17 +11,26 @@
|
||||
# use CACHE FORCE or set(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ ON) or delete CMakecache.txt or the entirely build dir
|
||||
# if your changes don't execute
|
||||
|
||||
option(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF)
|
||||
option(ENABLE_PNG "Enable the use of PNG" OFF)
|
||||
option(LIBPNG_FROM_OS "Use libpng from operating system." ON)
|
||||
option(ENABLE_JPEG "Enable the use of JPEG" OFF)
|
||||
option(LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
||||
option(ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
||||
option(CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." OFF)
|
||||
option(CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." ON)
|
||||
option(BUILD_NANA_DEMOS "Build all the demos form the nana_demo repository." OFF)
|
||||
# It seems that project() defines essential system variables like CMAKE_FIND_LIBRARY_PREFIXES.
|
||||
# https://bbs.archlinux.org/viewtopic.php?id=84967
|
||||
project(nana)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# The ISO C++ File System Technical Specification is optional.
|
||||
set(NANA_LINKS)
|
||||
|
||||
option(NANA_CMAKE_INSTALL_INCLUDES "Install nana includes when compile the library" ON)
|
||||
option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF)
|
||||
option(NANA_CMAKE_ENABLE_PNG "Enable the use of PNG" OFF)
|
||||
option(NANA_CMAKE_LIBPNG_FROM_OS "Use libpng from operating system." ON)
|
||||
option(NANA_CMAKE_ENABLE_JPEG "Enable the use of JPEG" OFF)
|
||||
option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
||||
option(NANA_CMAKE_ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
||||
option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." OFF)
|
||||
option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." ON)
|
||||
option(NANA_CMAKE_BUILD_DEMOS "Build all the demos form the nana_demo repository." OFF)
|
||||
option(NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS "" ON)
|
||||
|
||||
# The ISO C++ File System Technical Specification (ISO-TS, or STD) is optional.
|
||||
# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
||||
# This is not a workaround, but an user option.
|
||||
# The library maybe available in the std library in use or from Boost (almost compatible)
|
||||
@ -29,31 +38,51 @@ option(BUILD_NANA_DEMOS "Build all the demos form the nana_demo repository." OFF
|
||||
# or you can choose to use the (partial, but functional) implementation provided by nana.
|
||||
# If you include the file <nana/filesystem/filesystem_selector.hpp>
|
||||
# The selected option will be set by nana into std::experimental::filesystem
|
||||
# By default Nana will use the ISO TS if available, or nana if not.
|
||||
# Boost will be use only if you change one of the following:
|
||||
option(CMAKE_BOOST_FILESYSTEM_AVAILABLE "Is Boost filesystem available?" OFF)
|
||||
option(NANA_BOOST_FILESYSTEM_PREFERRED "Is Boost filesystem preferred over nana?" OFF)
|
||||
option(CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over ISO)?" OFF)
|
||||
option(CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find <boost/filesystem.hpp>?" "../")
|
||||
option(CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs")
|
||||
# By default Nana will try to use the STD. If not available will try
|
||||
# to use boost if available. Nana own implementation will be use only none of them are available.
|
||||
# You can change that default if you change one of the following
|
||||
# (please don't define more than one of the _XX_FORCE options):
|
||||
option(NANA_CMAKE_FIND_BOOST_FILESYSTEM "Search: Is Boost filesystem available?" ON)
|
||||
option(NANA_CMAKE_NANA_FILESYSTEM_FORCE "Force nana filesystem over ISO and boost?" OFF)
|
||||
option(NANA_CMAKE_STD_FILESYSTEM_FORCE "Use of STD filesystem?(a compilation error will ocurre if not available)" OFF)
|
||||
option(NANA_CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over STD)?" OFF)
|
||||
# cmake will find the package self, if don't works set the following (please find the correct values):
|
||||
#option(NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find <boost/filesystem.hpp>?" "../")
|
||||
#option(NANA_CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs")
|
||||
#include_directories("${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}")
|
||||
#list(APPEND NANA_LINKS "${NANA_CMAKE_BOOST_FILESYSTEM_LIB}")
|
||||
|
||||
set(NANA_LINKS)
|
||||
|
||||
if (CMAKE_BOOST_FILESYSTEM_AVAILABLE)
|
||||
if (CMAKE_BOOST_FILESYSTEM_PREFERED OR CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||
if (NANA_CMAKE_NANA_FILESYSTEM_FORCE)
|
||||
add_definitions(-DNANA_FILESYSTEM_FORCE)
|
||||
|
||||
elseif (NANA_CMAKE_STD_FILESYSTEM_FORCE)
|
||||
add_definitions(-DSTD_FILESYSTEM_FORCE)
|
||||
|
||||
elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||
|
||||
if (NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||
add_definitions(-DNANA_BOOST_FILESYSTEM_FORCE)
|
||||
endif(NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||
|
||||
# https://cmake.org/cmake/help/git-master/module/FindBoost.html
|
||||
# Implicit dependencies such as Boost::filesystem requiring Boost::system will be automatically detected and satisfied,
|
||||
# even if system is not specified when using find_package and if Boost::system is not added to target_link_libraries.
|
||||
# If using Boost::thread, then Thread::Thread will also be added automatically.
|
||||
find_package(Boost COMPONENTS filesystem)
|
||||
if (Boost_FOUND)
|
||||
add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE)
|
||||
if (CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||
add_definitions(-DNANA_BOOST_FILESYSTEM_FORCE)
|
||||
else()
|
||||
add_definitions(-DNANA_BOOST_FILESYSTEM_PREFERED)
|
||||
endif()
|
||||
include_directories("${CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}")
|
||||
list(APPEND NANA_LINKS "${CMAKE_BOOST_FILESYSTEM_LIB}")
|
||||
endif (CMAKE_BOOST_FILESYSTEM_PREFERED OR CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||
endif (CMAKE_BOOST_FILESYSTEM_AVAILABLE)
|
||||
include_directories(SYSTEM "${Boost_INCLUDE_DIR}")
|
||||
list(APPEND NANA_LINKS "${Boost_LIBRARIES}")
|
||||
endif (Boost_FOUND)
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_STATIC_RUNTIME ON) # ??
|
||||
#set(Boost_USE_MULTITHREADED ON)
|
||||
|
||||
endif (NANA_CMAKE_NANA_FILESYSTEM_FORCE)
|
||||
|
||||
|
||||
project(nana)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Compatibility with CMake 3.1
|
||||
if(POLICY CMP0054)
|
||||
@ -76,9 +105,9 @@ if(WIN32)
|
||||
endif(MSVC)
|
||||
|
||||
if(MINGW)
|
||||
if(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||
if(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||
add_definitions(-DNANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||
endif(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||
endif(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||
endif(MINGW)
|
||||
elseif(WIN32)
|
||||
set(BUILD_FreeMe OFF)
|
||||
@ -106,34 +135,34 @@ if(UNIX)
|
||||
endif(UNIX)
|
||||
|
||||
#Find PNG
|
||||
if(ENABLE_PNG)
|
||||
if(NANA_CMAKE_ENABLE_PNG)
|
||||
add_definitions(-DNANA_ENABLE_PNG)
|
||||
#set(NANA_PNG_LIB "png")
|
||||
list(APPEND NANA_LINKS -lpng )
|
||||
if(LIBPNG_FROM_OS)
|
||||
if(NANA_CMAKE_LIBPNG_FROM_OS)
|
||||
find_package(PNG)
|
||||
if (PNG_FOUND)
|
||||
include_directories( ${PNG_INCLUDE_DIRS})
|
||||
add_definitions(-DUSE_LIBPNG_FROM_OS)
|
||||
endif(PNG_FOUND)
|
||||
endif(LIBPNG_FROM_OS)
|
||||
endif(ENABLE_PNG)
|
||||
endif(NANA_CMAKE_LIBPNG_FROM_OS)
|
||||
endif(NANA_CMAKE_ENABLE_PNG)
|
||||
|
||||
#Find JPEG
|
||||
if(ENABLE_JPEG)
|
||||
if(NANA_CMAKE_ENABLE_JPEG)
|
||||
add_definitions(-DNANA_ENABLE_JPEG)
|
||||
#set(NANA_JPEG_LIB "jpeg")
|
||||
list(APPEND NANA_LINKS -ljpeg )
|
||||
if(LIBJPEG_FROM_OS)
|
||||
if(NANA_CMAKE_LIBJPEG_FROM_OS)
|
||||
find_package(JPEG)
|
||||
if (JPEG_FOUND)
|
||||
include_directories( ${JPEG_INCLUDE_DIRS})
|
||||
add_definitions(-DUSE_LIBJPEG_FROM_OS)
|
||||
endif(JPEG_FOUND)
|
||||
endif(LIBJPEG_FROM_OS)
|
||||
endif(ENABLE_JPEG)
|
||||
endif(NANA_CMAKE_LIBJPEG_FROM_OS)
|
||||
endif(NANA_CMAKE_ENABLE_JPEG)
|
||||
|
||||
if(ENABLE_AUDIO)
|
||||
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||
add_definitions(-DNANA_ENABLE_AUDIO)
|
||||
if(UNIX)
|
||||
find_package(ASOUND)
|
||||
@ -144,11 +173,11 @@ if(ENABLE_AUDIO)
|
||||
message(FATAL_ERROR "libasound is not found")
|
||||
endif(ASOUND_FOUND)
|
||||
endif(UNIX)
|
||||
endif(ENABLE_AUDIO)
|
||||
endif(NANA_CMAKE_ENABLE_AUDIO)
|
||||
|
||||
if(CMAKE_VERBOSE_PREPROCESSOR)
|
||||
if(NANA_CMAKE_VERBOSE_PREPROCESSOR)
|
||||
add_definitions(-DVERBOSE_PREPROCESSOR)
|
||||
endif(CMAKE_VERBOSE_PREPROCESSOR)
|
||||
endif(NANA_CMAKE_VERBOSE_PREPROCESSOR)
|
||||
|
||||
|
||||
set(NANA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
|
||||
@ -166,7 +195,7 @@ aux_source_directory(${NANA_SOURCE_DIR}/paint NANA_PAINT_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/paint/detail NANA_PAINT_DETAIL_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/system NANA_SYSTEM_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/threads NANA_THREADS_SOURCE)
|
||||
if(ENABLE_AUDIO)
|
||||
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/audio NANA_AUDIO_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/audio/detail NANA_AUDIO_DETAIL_SOURCE)
|
||||
endif()
|
||||
@ -197,14 +226,23 @@ install(TARGETS ${PROJECT_NAME}
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib)
|
||||
|
||||
# Install include directories too.
|
||||
if(NANA_CMAKE_INSTALL_INCLUDES)
|
||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/nana
|
||||
DESTINATION include)
|
||||
endif(NANA_CMAKE_INSTALL_INCLUDES)
|
||||
|
||||
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
|
||||
|
||||
# TODO: move this nana-demo section to the nana demo repository, and here only include that cmake file
|
||||
|
||||
if (BUILD_NANA_DEMOS)
|
||||
if (NANA_CMAKE_BUILD_DEMOS)
|
||||
|
||||
set (demos calculator notepad widget_show widget_show2 )
|
||||
# Pending: file_explorer FreeMe
|
||||
set (demos calculator helloworld_demo notepad widget_show widget_show2 )
|
||||
if (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS)
|
||||
list(APPEND demos file_explorer)
|
||||
endif (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS)
|
||||
# Pending: FreeMe
|
||||
|
||||
foreach ( demo ${demos})
|
||||
add_executable(${demo} "../nana-demo/${demo}.cpp")
|
||||
@ -233,7 +271,7 @@ if (BUILD_NANA_DEMOS)
|
||||
message("... to build: ../nana-demo/Examples/${demo}.cpp" )
|
||||
endforeach( demo ${demos})
|
||||
|
||||
endif (BUILD_NANA_DEMOS)
|
||||
endif (NANA_CMAKE_BUILD_DEMOS)
|
||||
|
||||
|
||||
# set compile flags
|
||||
@ -262,6 +300,13 @@ message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG})
|
||||
message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS})
|
||||
message ( "CMAKE_COMPILER_IS_GNUCXX= " ${CMAKE_COMPILER_IS_GNUCXX})
|
||||
message ( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS})
|
||||
message ( "DESTDIR = " ${DESTDIR})
|
||||
message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX})
|
||||
message ( "NANA_LINKS = " ${NANA_LINKS})
|
||||
message ( "ENABLE_AUDIO = " ${ENABLE_AUDIO})
|
||||
message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO})
|
||||
message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM})
|
||||
message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE})
|
||||
message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT})
|
||||
message ( "NANA_CMAKE_BOOST_FILESYSTEM_LIB = " ${NANA_CMAKE_BOOST_FILESYSTEM_LIB})
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
Building Nana C++ Library
|
||||
requires:
|
||||
# Building Nana C++ Library directly with make
|
||||
If you are using make directly, it require:
|
||||
X11, pthread, Xpm, rt, dl, freetype2, Xft, fontconfig, ALSA
|
||||
|
||||
Writing a makefile for creating applications with Nana C++ Library
|
||||
Example of writing a makefile for creating applications with Nana C++ Library
|
||||
-------------------
|
||||
```
|
||||
GCC = g++
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
* - _SCL_SECURE_NO_WARNNGS, _CRT_SECURE_NO_DEPRECATE (VC)
|
||||
* - STD_CODECVT_NOT_SUPPORTED (VC RC, <codecvt> is a known issue on libstdc++, it works on libc++)
|
||||
* - STD_THREAD_NOT_SUPPORTED (GCC < 4.8.1)
|
||||
* - STD_put_time_NOT_SUPPORTED (GCC < 5)
|
||||
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
|
||||
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
|
||||
* - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8)
|
||||
@ -133,8 +134,13 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if ((__GNUC__ < 5) )
|
||||
# define STD_put_time_NOT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) )
|
||||
#undef STD_FILESYSTEM_NOT_SUPPORTED
|
||||
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ == 4)
|
||||
|
||||
@ -39,20 +39,30 @@
|
||||
// https://github.com/meganz/mingw-std-threads
|
||||
//#define NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ
|
||||
|
||||
////////////////////////////
|
||||
// The ISO C++ File System Technical Specification is optional.
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
||||
// This is not a workaround, but an user option.
|
||||
// The library maybe available in the std library in use or from Boost (almost compatible)
|
||||
// http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm
|
||||
// or you can choose to use the (partial, but functional) implementation provided by nana.
|
||||
// If you include the file <nana/filesystem/filesystem_selector.hpp>
|
||||
// The selected option will be set by nana into std::experimental::filesystem
|
||||
// By default Nana will use the ISO TS if available, or nana if not.
|
||||
// Boost will be use only if you change one of the following (set the includes and link correspondly):
|
||||
//#define NANA_BOOST_FILESYSTEM_AVAILABLE // "Is Boost filesystem available?"
|
||||
//#define NANA_BOOST_FILESYSTEM_PREFERRED // "Is Boost filesystem preferred over nana?"
|
||||
//#define NANA_BOOST_FILESYSTEM_FORCE // "Force use of Boost filesystem if available (over ISO)?
|
||||
//# The ISO C++ File System Technical Specification(ISO - TS, or STD) is optional.
|
||||
//# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
||||
//# This is not a workaround, but an user option.
|
||||
//# The library maybe available in the std library in use or from Boost(almost compatible)
|
||||
//# http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm
|
||||
//# or you can choose to use the(partial, but functional) implementation provided by nana.
|
||||
//# If you include the file <nana/filesystem/filesystem_selector.hpp>
|
||||
//# the selected option will be set by nana into std::experimental::filesystem
|
||||
//# By default Nana will try to use the STD.If not available will try
|
||||
//# to use boost if available.Nana own implementation will be use only none of them are available.
|
||||
//# You can change that default if you change one of the following
|
||||
//# (please don't define more than one of the _XX_FORCE options):
|
||||
//
|
||||
//#define BOOST_FILESYSTEM_AVAILABLE // "Is Boost filesystem available?"
|
||||
//#define BOOST_FILESYSTEM_FORCE // "Force use of Boost filesystem if available (over ISO and nana)
|
||||
//#define STD_FILESYSTEM_FORCE // "Use of STD filesystem?(a compilation error will ocurre if not available)" OFF)
|
||||
//#define NANA_FILESYSTEM_FORCE // "Force nana filesystem over ISO and boost?" OFF)
|
||||
//
|
||||
// Make sure you (cmake?) provide the following where correspond (please find the correct values):
|
||||
// set CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find <boost/filesystem.hpp>?" "../")
|
||||
// set CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs")
|
||||
// include_directories CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT
|
||||
// APPEND flag LINKS CMAKE_BOOST_FILESYSTEM_LIB
|
||||
|
||||
|
||||
///////////////////
|
||||
// Support of PCM playback
|
||||
|
||||
@ -92,6 +92,25 @@ namespace std
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef STD_put_time_NOT_SUPPORTED
|
||||
#include <ctime>
|
||||
namespace std
|
||||
{
|
||||
//Workaround for no implemenation of std::put_time in gcc < 5.
|
||||
/* std unspecified return type */
|
||||
//template< class CharT, class RTSTR >// let fail for CharT != char / wchar_t
|
||||
//RTSTR put_time(const std::tm* tmb, const CharT* fmt);
|
||||
|
||||
//template< >
|
||||
std::string put_time/*<char, std::string>*/(const std::tm* tmb, const char* fmt);
|
||||
|
||||
//Defined in header <ctime>
|
||||
// std::size_t strftime(char* str, std::size_t count, const char* format, const std::tm* time);
|
||||
//template<>
|
||||
//std::wstring put_time<wchar_t, std::wstring>(const std::tm* tmb, const wchar_t* fmt);
|
||||
}
|
||||
#endif // STD_put_time_NOT_SUPPORTED
|
||||
|
||||
namespace nana
|
||||
{
|
||||
/// Checks whether a specified text is utf8 encoding
|
||||
|
||||
@ -112,7 +112,7 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
public:
|
||||
#if defined(NANA_WINDOWS)
|
||||
using value_type = wchar_t;
|
||||
const static value_type preferred_separator = '\\'; //? L'\\' ?
|
||||
const static value_type preferred_separator = L'\\'; //? L'\\' ?
|
||||
#else
|
||||
using value_type = char;
|
||||
const static value_type preferred_separator = '/';
|
||||
@ -127,23 +127,41 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
_m_assign(source);
|
||||
}
|
||||
|
||||
// modifiers
|
||||
//void clear() noexcept;
|
||||
path& make_preferred();
|
||||
path& remove_filename();
|
||||
//path& replace_filename(const path& replacement);
|
||||
//path& replace_extension(const path& replacement = path());
|
||||
//void swap(path& rhs) noexcept;
|
||||
|
||||
// decomposition
|
||||
//path root_name() const;
|
||||
//path root_directory() const;
|
||||
//path root_path() const;
|
||||
//path relative_path() const;
|
||||
path parent_path() const;
|
||||
path filename() const;
|
||||
//path stem() const;
|
||||
path extension() const;
|
||||
|
||||
// query
|
||||
bool empty() const noexcept;
|
||||
//bool has_root_name() const;
|
||||
//bool has_root_directory() const;
|
||||
//bool has_root_path() const;
|
||||
//bool has_relative_path() const;
|
||||
bool has_parent_path() const { return !parent_path().string().empty(); }; // temp;;
|
||||
bool has_filename() const { return !filename().string().empty(); }; // temp;
|
||||
//bool has_stem() const;
|
||||
bool has_extension() const { return !extension().string().empty(); }; // temp
|
||||
//bool is_absolute() const;
|
||||
//bool is_relative() const;
|
||||
|
||||
int compare(const path& other) const;
|
||||
|
||||
bool empty() const;
|
||||
path extension() const;
|
||||
|
||||
path parent_path() const;
|
||||
file_type what() const;
|
||||
|
||||
//decomposition
|
||||
path filename() const;
|
||||
|
||||
//modifiers
|
||||
path& remove_filename();
|
||||
|
||||
|
||||
|
||||
const value_type*c_str() const;
|
||||
const string_type& native() const;
|
||||
operator string_type() const;
|
||||
@ -335,16 +353,21 @@ 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&);
|
||||
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().
|
||||
file_time_type last_write_time(const path& p);
|
||||
/// 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);
|
||||
void current_path(const path& p); ///< chdir
|
||||
//void current_path(const path& p, error_code& ec) noexcept;
|
||||
|
||||
|
||||
bool remove(const path& p);
|
||||
bool remove(const path& p, std::error_code& ec); // noexcept;
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#ifndef NANA_FILESYSTEM_EXT_HPP
|
||||
#define NANA_FILESYSTEM_EXT_HPP
|
||||
|
||||
#include <iomanip>
|
||||
#include <nana/filesystem/filesystem_selector.hpp>
|
||||
|
||||
namespace nana {namespace experimental {namespace filesystem {namespace ext {
|
||||
@ -108,6 +109,54 @@ 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 {
|
||||
std::size_t 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];
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
catch (...) {}
|
||||
return {};
|
||||
}
|
||||
|
||||
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 {};
|
||||
}
|
||||
}
|
||||
|
||||
}}}}
|
||||
#endif //NANA_FILESYSTEM_EXT_HPP
|
||||
|
||||
@ -9,16 +9,17 @@
|
||||
* @file nana\filesystem\filesystem_selector.hpp
|
||||
* @autor by Ariel Vina-Rodriguez:
|
||||
* @brief A "ISO C++" filesystem Implementation selector
|
||||
* The ISO C++ File System Technical Specification is optional.
|
||||
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
||||
* This is not a workaround, but an user option.
|
||||
* The library maybe available in the std library in use or from Boost (almost compatible)
|
||||
* http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm
|
||||
* or you can choose to use the (partial, but functional) implementation provided by nana.
|
||||
* If you include the file <nana/filesystem/filesystem_selector.hpp>
|
||||
* The selected option will be set by nana into std::experimental::filesystem
|
||||
* By default Nana will use the ISO TS if available, or nana if not.
|
||||
* Boost will be use only if explicitily changed
|
||||
*
|
||||
* The ISO C++ File System Technical Specification(ISO - TS, or STD) is optional.
|
||||
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
||||
* This is not a workaround, but an user option.
|
||||
* The library maybe available in the std library in use or from Boost(almost compatible)
|
||||
* http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm
|
||||
* or you can choose to use the(partial, but functional) implementation provided by nana.
|
||||
* If you include the file <nana/filesystem/filesystem_selector.hpp>
|
||||
* the selected option will be set by nana into std::experimental::filesystem
|
||||
* By default Nana will try to use the STD. If not available will try
|
||||
* to use boost if available. Nana own implementation will be use only if none of them are available.
|
||||
* nana Now mimic std::experimental::filesystem::v1 (boost v3)
|
||||
*
|
||||
*/
|
||||
@ -28,27 +29,7 @@
|
||||
|
||||
#include <nana/config.hpp>
|
||||
|
||||
#if (!defined(NANA_FILESYSTEM_FORCE) && defined(NANA_BOOST_FILESYSTEM_AVAILABLE) && ( defined(NANA_BOOST_FILESYSTEM_FORCE) || (defined(STD_FILESYSTEM_NOT_SUPPORTED) && defined(NANA_BOOST_FILESYSTEM_PREFERRED) ) ))
|
||||
|
||||
# include <boost/filesystem.hpp>
|
||||
|
||||
// add boost::filesystem into std::experimental::filesystem
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
namespace filesystem {
|
||||
|
||||
# ifdef CXX_NO_INLINE_NAMESPACE
|
||||
using namespace boost::experimental::filesystem;
|
||||
# else
|
||||
using namespace boost::experimental::filesystem::v3;
|
||||
# endif
|
||||
|
||||
} // filesystem
|
||||
} // experimental
|
||||
} // std
|
||||
|
||||
|
||||
#elif (defined(NANA_FILESYSTEM_FORCE) || defined(STD_FILESYSTEM_NOT_SUPPORTED))
|
||||
#if (defined(NANA_FILESYSTEM_FORCE) || ( (defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(BOOST_FILESYSTEM_AVAILABLE)) && !(defined(BOOST_FILESYSTEM_FORCE) || defined(STD_FILESYSTEM_FORCE)) ) )
|
||||
|
||||
# include <nana/filesystem/filesystem.hpp>
|
||||
|
||||
@ -57,17 +38,30 @@ namespace std {
|
||||
namespace filesystem {
|
||||
|
||||
# ifdef CXX_NO_INLINE_NAMESPACE
|
||||
using namespace nana::experimental::filesystem;
|
||||
using namespace nana::experimental::filesystem;
|
||||
# else
|
||||
using namespace nana::experimental::filesystem::v1;
|
||||
using namespace nana::experimental::filesystem::v1;
|
||||
# endif
|
||||
|
||||
} // filesystem
|
||||
} // experimental
|
||||
} // std
|
||||
|
||||
#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) ))
|
||||
|
||||
# include <boost/filesystem.hpp>
|
||||
|
||||
// add boost::filesystem into std::experimental::filesystem
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
namespace filesystem {
|
||||
using namespace boost::filesystem;
|
||||
} // filesystem
|
||||
} // experimental
|
||||
} // std
|
||||
|
||||
#else
|
||||
# include <filesystem>
|
||||
# include <experimental/filesystem>
|
||||
#endif
|
||||
|
||||
#ifndef __cpp_lib_experimental_filesystem
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
/**
|
||||
* \file basis.hpp
|
||||
* \brief This file provides basis class and data structures required by the GUI
|
||||
*
|
||||
* Basis 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
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/basis.hpp
|
||||
*
|
||||
* This file provides basis class and data structrue that required by gui
|
||||
*/
|
||||
|
||||
#ifndef NANA_GUI_BASIS_HPP
|
||||
@ -151,7 +151,25 @@ namespace nana
|
||||
appearance();
|
||||
appearance(bool has_decoration, bool taskbar, bool floating, bool no_activate, bool min, bool max, bool sizable);
|
||||
};
|
||||
/// Provided to generate an appearance object with better readability and understandability
|
||||
|
||||
|
||||
/** @brief Provided to generate an appearance object with better readability and understandability
|
||||
|
||||
A window has an appearance. This appearance can be specified when a window is being created.
|
||||
To determine the appearance of a window there is a structure named nana::appearance with
|
||||
a bool member for each feature with can be included or excluded in the "apereance" of the windows form.
|
||||
But in practical development is hard to describe the style of the appearance using the struct nana::appearance.
|
||||
If a form would to be defined without min/max button and sizable border, then
|
||||
|
||||
\code{.CPP}
|
||||
nana::form form(x, y, width, height, nana::appearance(false, false, false, true, false));
|
||||
\endcode
|
||||
|
||||
This piece of code may be confusing because of the 5 parameters of the constructor of `nana::form`. So the library provides a helper class for making it easy.
|
||||
For better readability and understandability Nana provides three templates classes to generate an appearance object:
|
||||
nana::appear::decorate, nana::appear::bald and nana::appear::optional. Each provide an operator
|
||||
that return a corresponding nana::appearance with predefined values.
|
||||
*/
|
||||
struct appear
|
||||
{
|
||||
struct minimize{};
|
||||
@ -160,7 +178,20 @@ namespace nana
|
||||
struct taskbar{};
|
||||
struct floating{};
|
||||
struct no_activate{};
|
||||
/// Create an appearance of a window with "decoration"
|
||||
|
||||
/** @brief Create an appearance of a window with "decoration" in non-client area, such as title bar
|
||||
*
|
||||
* We can create a form without min/max button and sizable border like this:
|
||||
* \code{.CPP}
|
||||
* using nana::appear;
|
||||
* nana::form form(x, y, width, height, appear::decorate<appear::taskbar>());
|
||||
* \endcode
|
||||
* The appearance created by appear::decorate<>() has a titlebar and borders that are draw by the
|
||||
* platform- window manager. If a window needs a minimize button, it should be:
|
||||
* \code{.CPP}
|
||||
* appear::decorate<appear::minimize, appear::taskbar>()
|
||||
* \endcode
|
||||
*/
|
||||
template< typename Minimize = null_type,
|
||||
typename Maximize = null_type,
|
||||
typename Sizable = null_type,
|
||||
@ -181,7 +212,8 @@ namespace nana
|
||||
);
|
||||
}
|
||||
};
|
||||
/// Create an appearance of a window without "decoration"
|
||||
|
||||
/// Create an appearance of a window without "decoration" with no titlebar and no 3D-look borders.
|
||||
template < typename Taskbar = null_type,
|
||||
typename Floating = null_type,
|
||||
typename NoActive = null_type,
|
||||
|
||||
@ -42,7 +42,7 @@ namespace nana
|
||||
void events_operation_cancel(event_handle);
|
||||
}//end namespace detail
|
||||
|
||||
/// base clase for all event argument types
|
||||
/// base class for all event argument types
|
||||
class event_arg
|
||||
{
|
||||
public:
|
||||
@ -57,7 +57,14 @@ namespace nana
|
||||
|
||||
struct general_events;
|
||||
|
||||
/// the type of the members of general_events
|
||||
/** @brief the type of the members of general_events.
|
||||
*
|
||||
* It connect the functions to be called as response to the event and manages that chain of responses
|
||||
* It is a functor, that get called to connect a "normal" response function, with normal "priority".
|
||||
* If a response function need another priority (unignorable or called first) it will need to be connected with
|
||||
* the specific connect function not with the operator()
|
||||
* It also permit to "emit" that event, calling all the active responders.
|
||||
*/
|
||||
template<typename Arg>
|
||||
class basic_event : public detail::event_interface
|
||||
{
|
||||
@ -68,6 +75,8 @@ namespace nana
|
||||
: public detail::docker_interface
|
||||
{
|
||||
basic_event * const event_ptr;
|
||||
|
||||
/// the callback/response function taking the typed argument
|
||||
std::function<void(arg_reference)> invoke;
|
||||
|
||||
bool flag_deleted{ false };
|
||||
@ -92,9 +101,10 @@ namespace nana
|
||||
}
|
||||
};
|
||||
|
||||
//class emit_counter is a RAII helper for emitting count
|
||||
//It is used for avoiding a try{}catch block which is required for some finial works when
|
||||
//event handlers throw exceptions.
|
||||
/// \brief RAII helper for emitting count.
|
||||
|
||||
/// It is used to avoid a try{}catch block which is required for some finial works when
|
||||
/// event handlers throw exceptions.
|
||||
class emit_counter
|
||||
{
|
||||
public:
|
||||
@ -133,11 +143,12 @@ namespace nana
|
||||
using prototype = typename std::remove_reference<Function>::type;
|
||||
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));
|
||||
dockers_->emplace(dockers_->begin(), std::move(dck)); // <---- the difference
|
||||
detail::events_operation_register(evt);
|
||||
return evt;
|
||||
}
|
||||
|
||||
/// It will not get called if stop_propagation() was called.
|
||||
event_handle connect(void (*fn)(arg_reference))
|
||||
{
|
||||
return connect([fn](arg_reference arg){
|
||||
@ -145,7 +156,7 @@ namespace nana
|
||||
});
|
||||
}
|
||||
|
||||
/// It will not get called if stop_propagation() was called.
|
||||
/// It will not get called if stop_propagation() was called, because it is set at the end of the chain..
|
||||
template<typename Function>
|
||||
event_handle connect(Function && fn)
|
||||
{
|
||||
@ -156,7 +167,7 @@ namespace nana
|
||||
using prototype = typename std::remove_reference<Function>::type;
|
||||
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));
|
||||
dockers_->emplace_back(std::move(dck)); // <---- the difference
|
||||
detail::events_operation_register(evt);
|
||||
return evt;
|
||||
}
|
||||
@ -187,12 +198,14 @@ namespace nana
|
||||
return evt;
|
||||
}
|
||||
|
||||
/// how many responses are registered?
|
||||
std::size_t length() const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
return (nullptr == dockers_ ? 0 : dockers_->size());
|
||||
}
|
||||
|
||||
/// by emitting the event it call each active response with the given arg.
|
||||
void emit(arg_reference& arg)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
@ -205,7 +218,7 @@ namespace nana
|
||||
const auto dockers_len = dockers.size();
|
||||
|
||||
//The dockers may resize when a new event handler is created by a calling handler.
|
||||
//Traverses with position can avaid crash error which caused by a iterator which becomes invalid.
|
||||
//Traverses with position can avoid crash error caused by an iterator which becomes invalid.
|
||||
for (std::size_t pos = 0; pos < dockers_len; ++pos)
|
||||
{
|
||||
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
|
||||
@ -221,7 +234,7 @@ namespace nana
|
||||
if (!docker_ptr->unignorable || docker_ptr->flag_deleted)
|
||||
continue;
|
||||
|
||||
docker_ptr->invoke(arg);
|
||||
docker_ptr->invoke(arg); // <--- finally call the response
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -418,11 +431,11 @@ namespace nana
|
||||
bool deleted_flags_{ false };
|
||||
std::unique_ptr<std::vector<std::unique_ptr<detail::docker_interface>>> dockers_;
|
||||
};
|
||||
|
||||
|
||||
struct arg_mouse
|
||||
: public event_arg
|
||||
{
|
||||
event_code evt_code; ///<
|
||||
event_code evt_code; ///< what kind of mouse event?
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
::nana::point pos; ///< cursor position in the event window
|
||||
::nana::mouse button; ///< indicates a button which triggers the event
|
||||
@ -441,7 +454,8 @@ namespace nana
|
||||
}
|
||||
};
|
||||
|
||||
/// in arg_wheel event_code is event_code::mouse_wheel
|
||||
/// \brief in arg_wheel event_code is event_code::mouse_wheel
|
||||
|
||||
/// The type arg_wheel is derived from arg_mouse, a handler
|
||||
/// with prototype void(const arg_mouse&) can be set for mouse_wheel.
|
||||
struct arg_wheel : public arg_mouse
|
||||
@ -473,7 +487,7 @@ namespace nana
|
||||
{
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
::nana::native_window_type receiver; ///< it is a native window handle, and specified which window receives focus
|
||||
bool getting; ///< the window received focus?
|
||||
bool getting; ///< the window received focus? (as oppose to losing focus)
|
||||
};
|
||||
|
||||
struct arg_keyboard : public event_arg
|
||||
@ -518,7 +532,7 @@ namespace nana
|
||||
{
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
};
|
||||
|
||||
/// a higher level event argument than just mouse down
|
||||
struct arg_click : public event_arg
|
||||
{
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
|
||||
@ -436,6 +436,49 @@ namespace std
|
||||
}
|
||||
#endif
|
||||
|
||||
//#ifdef STD_put_time_NOT_SUPPORTED
|
||||
#include <ctime>
|
||||
#include <cwchar>
|
||||
namespace std
|
||||
{
|
||||
//Workaround for no implemenation of std::put_time in gcc < 5.
|
||||
/* std unspecified return type */
|
||||
//template< class CharT, class RTSTR >// let fail for CharT != char / wchar_t
|
||||
//RTSTR put_time(const std::tm* tmb, const CharT* fmt);
|
||||
|
||||
//template< >
|
||||
std::string put_time/*<char, std::string>*/(const std::tm* tmb, const char* fmt)
|
||||
{
|
||||
unsigned sz = 200;
|
||||
std::string str(sz, '\0');
|
||||
sz = std::strftime(&str[0], str.size() - 1, fmt, tmb);
|
||||
str.resize(sz);
|
||||
return str;
|
||||
}
|
||||
//Defined in header <ctime>
|
||||
// std::size_t strftime(char* str, std::size_t count, const char* format, const std::tm* time);
|
||||
//template<>
|
||||
//std::wstring put_time<wchar_t, std::wstring>(const std::tm* tmb, const wchar_t* fmt)
|
||||
//{
|
||||
// unsigned sz = 200;
|
||||
// std::wstring str(sz, L'\0');
|
||||
// sz = std::wcsftime(&str[0], str.size() - 1, fmt, tmb);
|
||||
// str.resize(sz);
|
||||
// return str;
|
||||
//}
|
||||
// http://en.cppreference.com/w/cpp/chrono/c/wcsftime
|
||||
// Defined in header <cwchar>
|
||||
// std::size_t wcsftime(wchar_t* str, std::size_t count, const wchar_t* format, const std::tm* time);
|
||||
// Converts the date and time information from a given calendar time time to a null - terminated
|
||||
// wide character string str according to format string format.Up to count bytes are written.
|
||||
// Parameters
|
||||
// str - pointer to the first element of the wchar_t array for output
|
||||
// count - maximum number of wide characters to write
|
||||
// format - pointer to a null - terminated wide character string specifying the format of conversion.
|
||||
|
||||
}
|
||||
//#endif // STD_put_time_NOT_SUPPORTED
|
||||
|
||||
namespace nana
|
||||
{
|
||||
bool is_utf8(const char* str, unsigned len)
|
||||
|
||||
@ -110,7 +110,8 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
return pathstr_.compare(p.pathstr_);
|
||||
}
|
||||
|
||||
bool path::empty() const
|
||||
/// true if the path is empty, false otherwise. ??
|
||||
bool path::empty() const noexcept
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
return (::GetFileAttributes(pathstr_.c_str()) == INVALID_FILE_ATTRIBUTES);
|
||||
@ -122,17 +123,20 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
|
||||
path path::extension() const
|
||||
{
|
||||
// todo: make more globlal
|
||||
#if defined(NANA_WINDOWS)
|
||||
auto pos = pathstr_.find_last_of(L"\\/.");
|
||||
auto SLorP=L"\\/.";
|
||||
auto P=L'.';
|
||||
#else
|
||||
auto pos = pathstr_.find_last_of("\\/.");
|
||||
auto SLorP="\\/.";
|
||||
auto P='.';
|
||||
#endif
|
||||
if ((pos == pathstr_.npos) || (pathstr_[pos] != '.'))
|
||||
return path();
|
||||
auto pos = pathstr_.find_last_of(SLorP);
|
||||
|
||||
|
||||
if (pos + 1 == pathstr_.size())
|
||||
return path();
|
||||
if ( ( pos == pathstr_.npos)
|
||||
|| ( pathstr_[pos] != P )
|
||||
|| ( pos + 1 == pathstr_.size() ))
|
||||
return path();
|
||||
|
||||
return path(pathstr_.substr(pos));
|
||||
}
|
||||
@ -781,6 +785,13 @@ namespace nana { namespace experimental { namespace filesystem
|
||||
return false;
|
||||
}
|
||||
|
||||
file_time_type last_write_time(const path& p)
|
||||
{
|
||||
struct tm t;
|
||||
modified_file_time(p, t);
|
||||
std::chrono::system_clock::time_point dateTime =std::chrono::system_clock::from_time_t( mktime(&t) );
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
bool create_directory(const path& p)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user