Skip to content

Commit

Permalink
Adding implementation for createNewEmptyTempDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinGuillaume committed Mar 22, 2024
1 parent d31a176 commit b9b6b5f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/tool/tools/mdprep/src/gromacs/util.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <fstream>
#include <random>
#include <re2/re2.h>
//
#include "tools/mdprep/gromacs/inputs.hpp"
Expand Down Expand Up @@ -124,4 +125,20 @@ namespace VTX::Tool::Mdprep::Gromacs
p_.expectedOutputFilesIndexes.push_back( p_.arguments.size() - 1 );
}

fs::path createNewEmptyTempDirectory() noexcept
{
fs::path out = fs::temp_directory_path() / "VTX" / "tools" / "mdprep";
fs::create_directories( out );
std::random_device rd;
std::mt19937 gen( rd() );
std::uniform_int_distribution<uint32_t> distrib( 0, 0xffffffff );
std::string uniqueDirName { std::to_string( distrib( gen ) ) };
while ( fs::exists( out / uniqueDirName ) )
{
uniqueDirName = std::to_string( distrib( gen ) );
}
out /= uniqueDirName;
fs::create_directories( out );
return out.make_preferred();
}
} // namespace VTX::Tool::Mdprep::Gromacs

0 comments on commit b9b6b5f

Please sign in to comment.