diff --git a/example/ALL_Staggered.cpp b/example/ALL_Staggered.cpp index 328fb23916382ef59c26b2ea43bb56c2514289bc..5f6e5d64248b9e321b50e51feb28b70478e77198 100644 --- a/example/ALL_Staggered.cpp +++ b/example/ALL_Staggered.cpp @@ -228,6 +228,7 @@ int main(int argc, char** argv) jall->printVTKoutlines(CurrentStep); } catch (ALL::FilesystemErrorException &e) { std::cout << e.what() << std::endl; + std::exit(2); // Maybe also treat this error in some way, e.g. whether the simulation // should abort if no output could be written or not. } diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 12a1e44073d88cb5b633439ef4c25425cce1c384..029269dab8cd1e9dbf16cd0074965e73a6b1db07 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -44,6 +44,7 @@ install(TARGETS read_binary_output add_executable(ALL_Staggered ALL_Staggered.cpp) if(CM_ALL_VTK_OUTPUT) + target_compile_definitions(ALL_Staggered PRIVATE ALL_VTK_OUTPUT_EXAMPLE) target_include_directories(ALL_Staggered PUBLIC ${VTK_INCLUDE_DIRS}) target_link_libraries(ALL_Staggered PUBLIC ${VTK_LIBRARY_DIRS}) endif(CM_ALL_VTK_OUTPUT) @@ -111,6 +112,7 @@ if(CM_ALL_FORTRAN) add_executable(ALL_Staggered_f ALL_Staggered_f.F90) if(CM_ALL_VTK_OUTPUT) + target_compile_definitions(ALL_Staggered_f PRIVATE ALL_VTK_OUTPUT_EXAMPLE) target_include_directories(ALL_Staggered_f PUBLIC ${VTK_INCLUDE_DIRS}) target_link_libraries(ALL_Staggered_f PUBLIC ${VTK_LIBRARY_DIRS}) endif(CM_ALL_VTK_OUTPUT) diff --git a/include/ALL.hpp b/include/ALL.hpp index 2308e0a689838e7220b9090d5955e5cec15fcdeb..52efc823e26b696b52e9d846c4050e2d3a5ccce9 100644 --- a/include/ALL.hpp +++ b/include/ALL.hpp @@ -827,6 +827,15 @@ private: __FILE__, __func__, __LINE__, "Could not create output directory."); } + // check permission in case directory already existed, but had wrong + // permissions + struct stat attr; + stat(filename, &attr); + if( (attr.st_mode & S_IRWXU) != S_IRWXU) { + throw FilesystemErrorException( + __FILE__, __func__, __LINE__, + "Possibly already existing directory does not have correct permissions (rwx) for user"); + } } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 67946b019d1dafb26ccf88b105a758147865a308..68f5bca9eaa4941f610bccd21c4cc487e2d6c239 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,4 +2,7 @@ add_subdirectory(unit) if(CM_ALL_TESTS_INTEGRATION) add_subdirectory(feature) endif() +if(CM_ALL_FORTRAN) + add_subdirectory(fortran_error) +endif() # vim: sw=4 ts=4 et diff --git a/tests/fortran_error/CMakeLists.txt b/tests/fortran_error/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..bea56d3a98e9669612d002dd2fff8fff9c7581fa --- /dev/null +++ b/tests/fortran_error/CMakeLists.txt @@ -0,0 +1,3 @@ + + +# vim: et sw=4 ts=4