20 lines
No EOL
536 B
C++
20 lines
No EOL
536 B
C++
#include "openMode.hpp"
|
|
|
|
|
|
|
|
namespace atlas::utils::file {
|
|
|
|
std::ios_base::openmode getOpenMode(const std::string& mode) {
|
|
// initialise an empty flags
|
|
auto flags = static_cast<std::ios_base::openmode>(0);
|
|
|
|
// set the flags
|
|
if (mode.find('r') != std::string::npos) flags |= std::ios::in;
|
|
if (mode.find('w') != std::string::npos) flags |= std::ios::out;
|
|
if (mode.find('a') != std::string::npos) flags |= std::ios::app;
|
|
if (mode.find('b') != std::string::npos) flags |= std::ios::binary;
|
|
|
|
return flags;
|
|
}
|
|
|
|
} |