Skip to content
Snippets Groups Projects
Commit 9f3556e6 authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon
Browse files

Use kwsys instead of posix for directory creation

parent 74af5c41
No related branches found
No related tags found
Loading
...@@ -48,6 +48,7 @@ target_include_directories(adios2 ...@@ -48,6 +48,7 @@ target_include_directories(adios2
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
PRIVATE ${ADIOS2_SOURCE_DIR}/source PRIVATE ${ADIOS2_SOURCE_DIR}/source
) )
target_link_libraries(adios2 PRIVATE adios2sys)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
target_link_libraries(adios2 PUBLIC ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(adios2 PUBLIC ${CMAKE_THREAD_LIBS_INIT})
......
...@@ -9,12 +9,11 @@ ...@@ -9,12 +9,11 @@
*/ */
#include "adiosSystem.h" #include "adiosSystem.h"
#include <sys/stat.h> //stat, mkdir #include <ctime> //std::ctime
#include <sys/types.h> //CreateDirectory
#include <unistd.h> //CreateDirectory
#include <chrono> //system_clock, now #include <chrono> //system_clock, now
#include <ctime> //std::ctime
#include <adios2sys/SystemTools.hxx>
#include "adios2/ADIOSMPI.h" #include "adios2/ADIOSMPI.h"
#include "adios2/ADIOSTypes.h" #include "adios2/ADIOSTypes.h"
...@@ -25,44 +24,7 @@ namespace adios2 ...@@ -25,44 +24,7 @@ namespace adios2
bool CreateDirectory(const std::string &fullPath) noexcept bool CreateDirectory(const std::string &fullPath) noexcept
{ {
auto lf_Mkdir = [](const std::string directory, struct stat &st) -> bool { return adios2sys::SystemTools::MakeDirectory(fullPath);
if (stat(directory.c_str(), &st) == -1) // doesn't exist
{
mkdir(directory.c_str(), 0777);
if (stat(directory.c_str(), &st) == -1) // doesn't exist
{
return false;
}
}
return true;
};
bool directoryExists = false;
auto directoryPosition = fullPath.find("/");
if (fullPath[0] == '/' || fullPath[0] == '.')
{ // find the second '/'
directoryPosition = fullPath.find("/", directoryPosition + 1);
}
struct stat st = {0};
if (directoryPosition == fullPath.npos) // no subdirectories
{
directoryExists = lf_Mkdir(fullPath.c_str(), st);
}
else
{
std::string directory(fullPath.substr(0, directoryPosition));
lf_Mkdir(directory.c_str(), st);
while (directoryPosition != fullPath.npos)
{
directoryPosition = fullPath.find("/", directoryPosition + 1);
directory = fullPath.substr(0, directoryPosition);
directoryExists = lf_Mkdir(directory.c_str(), st);
}
}
return directoryExists;
} }
bool IsLittleEndian() noexcept bool IsLittleEndian() noexcept
......
set(KWSYS_NAMESPACE adios2sys) set(KWSYS_NAMESPACE adios2sys)
set(KWSYS_USE_DynamicLoader ON) set(KWSYS_USE_DynamicLoader ON)
set(KWSYS_USE_RegularExpression ON)
set(KWSYS_USE_SystemTools ON)
set(KWSYS_BUILD_SHARED OFF) set(KWSYS_BUILD_SHARED OFF)
if(NOT ADIOS2_BUILD_SHARED_LIBS) if(NOT ADIOS2_BUILD_SHARED_LIBS)
set(KWSYS_INSTALL_EXPORT_NAME adios2) set(KWSYS_INSTALL_EXPORT_NAME adios2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment