mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
receiver create path (#35)
This commit is contained in:

committed by
Dhanya Thattil

parent
136e00d15e
commit
d3101baacb
@ -1,9 +1,12 @@
|
||||
#include "file_utils.h"
|
||||
#include "logger.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) {
|
||||
int ichan, iline=0;
|
||||
@ -77,5 +80,25 @@ int writeDataFile(std::string fname,int nch, short int *data) {
|
||||
|
||||
|
||||
|
||||
void mkdir_p(const std::string& path, std::string dir) {
|
||||
if (path.length() == 0)
|
||||
return;
|
||||
|
||||
size_t i = 0;
|
||||
for (; i < path.length(); i++) {
|
||||
dir += path[i];
|
||||
if (path[i] == '/')
|
||||
break;
|
||||
}
|
||||
if(mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0){
|
||||
if (errno != EEXIST)
|
||||
throw sls::RuntimeError("Could not create: " + dir);
|
||||
}
|
||||
|
||||
if (i + 1 < path.length())
|
||||
mkdir_p(path.substr(i + 1), dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user