From 2b6c8e01804c67fdceaf30e56af249d98ce505e5 Mon Sep 17 00:00:00 2001 From: Vina Rodriguez Date: Tue, 19 Mar 2019 20:00:55 +0100 Subject: [PATCH 1/4] fix crash by using empty path to initialize folderbox with fs canonical() which don't exist --- source/gui/filebox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index 5b2db9e2..aff5b2a7 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -1359,7 +1359,7 @@ namespace nana path.resize(len); impl_->path = to_utf8(path); - } + } #endif } @@ -1589,7 +1589,7 @@ namespace nana }; folderbox::folderbox(window owner, const path_type& init_path, std::string title) - : impl_(new implement{ owner, fs::canonical(init_path).make_preferred(), title, false}) + : impl_(new implement{ owner, fs::weakly_canonical(init_path).make_preferred(), title, false}) {} From ea3082239bc8b429bfcd65a2bc7bcec5210177e7 Mon Sep 17 00:00:00 2001 From: Vina Rodriguez Date: Tue, 19 Mar 2019 20:04:31 +0100 Subject: [PATCH 2/4] implement filesystem path stem() in nana --- include/nana/filesystem/filesystem.hpp | 2 +- source/filesystem/filesystem.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/nana/filesystem/filesystem.hpp b/include/nana/filesystem/filesystem.hpp index f14c043f..beaa1545 100644 --- a/include/nana/filesystem/filesystem.hpp +++ b/include/nana/filesystem/filesystem.hpp @@ -254,7 +254,7 @@ namespace nana { namespace experimental { namespace filesystem path relative_path() const; path parent_path() const; path filename() const; - //path stem() const; + path stem() const; path extension() const; // query diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index b13e8465..061a12f7 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -225,8 +225,10 @@ namespace nana { namespace experimental { namespace filesystem //Because of No wide character version of POSIX #if defined(NANA_POSIX) const char* separators = "/"; + const char* punt = "."; #else const wchar_t* separators = L"/\\"; + const wchar_t* punt = L"."; #endif //class file_status @@ -453,6 +455,22 @@ namespace nana { namespace experimental { namespace filesystem return{ pathstr_ }; } + path path::stem() const + { + auto pos = pathstr_.find_last_of(separators); + auto ext = pathstr_.find_last_of(punt); + + if (pos == pathstr_.npos) + pos = 0; + else + pos++; + + if (ext == pathstr_.npos || ext < pos) + return path(pathstr_.substr(pos)); + else + return path(pathstr_.substr(pos, ext-pos)); + } + void path::clear() noexcept { pathstr_.clear(); From 83eab4ba6368dd6899795357d27b805ffb058f05 Mon Sep 17 00:00:00 2001 From: Vina Rodriguez Date: Tue, 19 Mar 2019 20:26:42 +0100 Subject: [PATCH 3/4] use gcc 8 to have weakly_canonical in travis ? --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08c3d6f0..5677645e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,11 @@ cache: matrix: include: - - env: CXX=g++-5 CC=gcc-5 + - env: CXX=g++-8 addons: apt: packages: - - g++-5 + - g++-8 - libjpeg8-dev - libpng-dev - libasound2-dev @@ -21,7 +21,7 @@ matrix: - libx11-dev - libxft-dev - libxcursor-dev - sources: + sources: - ubuntu-toolchain-r-test allow_failures: From db0812fdabe4a3bd4b6d1053dbf13ba4145350d0 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 20 Mar 2019 17:26:38 +0100 Subject: [PATCH 4/4] nana hotfix point to nana-demo hotfix. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5677645e..7b71b9ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ matrix: before_install: - cd .. - - git clone --depth=1 --branch=cmake-dev https://github.com/qPCR4vir/nana-demo.git nana-demo + - git clone --depth=1 --branch=hotfix https://github.com/qPCR4vir/nana-demo.git nana-demo - export PATH="$HOME/bin:$PATH" #- mkdir ~/bin #it seemd that a bin already exists from 20170901