build types, untested recursive_remove function in fs

This commit is contained in:
Nicholas O'Connor 2017-03-27 21:03:35 -07:00
parent f505469ce9
commit 0adbe5e0d1
4 changed files with 29 additions and 1 deletions

View File

@ -3,6 +3,16 @@ project(cellar CXX)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS -pipe)
set(CMAKE_CXX_FLAGS_DEBUG -O0 -g)
set(CMAKE_CXX_FLAGS_RELEASE -O2)
set(CMAKE_CXX_FLAGS_RELWITHDBGINFO ${CMAKE_CXX_FLAGS_RELEASE} -g)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Assuming this is a release build. -DCMAKE_BUILD_TYPE=Debug otherwise.")
set(CMAKE_BUILD_TYPE Release FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# local cmake modules # local cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)

2
cogrc
View File

@ -1,3 +1,3 @@
[version] [version]
release=no release=no
release_version=00 release_version=0.1

View File

@ -11,6 +11,7 @@ namespace cellar {
namespace fs { namespace fs {
extern vector<string> listdir(string path); extern vector<string> listdir(string path);
extern bool recursive_copy(string, string); extern bool recursive_copy(string, string);
extern bool recursive_remove(string);
} }
} }

View File

@ -46,3 +46,20 @@ bool cellar::fs::recursive_copy(string src, string dst) {
return true; return true;
} }
bool cellar::fs::recursive_remove(string target) {
if (!filesystem::exists(target)) { return false; }
for (string itemrel : cellar::fs::listdir(target)) {
string itemabs = target + "/" + itemrel;
auto itemstat = filesystem::symlink_status(itemabs);
if (filesystem::is_directory(itemstat)) { recursive_remove(itemabs); }
else { filesystem::remove(itemabs); }
}
filesystem::remove(target);
return true;
}