build types, untested recursive_remove function in fs
This commit is contained in:
parent
f505469ce9
commit
0adbe5e0d1
@ -3,6 +3,16 @@ project(cellar CXX)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
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
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
|
||||
|
@ -11,6 +11,7 @@ namespace cellar {
|
||||
namespace fs {
|
||||
extern vector<string> listdir(string path);
|
||||
extern bool recursive_copy(string, string);
|
||||
extern bool recursive_remove(string);
|
||||
}
|
||||
}
|
||||
|
||||
|
17
src/fs.cpp
17
src/fs.cpp
@ -46,3 +46,20 @@ bool cellar::fs::recursive_copy(string src, string dst) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user