using std::string;
- struct IOErrorException : public std::exception
- {
- explicit IOErrorException() throw() {}
- virtual const char* what() const throw() { return "IO error"; }
- };
-
-
typedef std::function<void(const string& name, unsigned int status)> cmpdirs_cb_t;
virtual const char* what() const throw() { return "logic error"; }
};
+ struct IOErrorException : public std::exception
+ {
+ explicit IOErrorException() throw() {}
+ virtual const char* what() const throw() { return "IO error"; }
+ };
+
}
if (!entries.empty())
num = entries.rbegin()->num + 1;
- mkdir((snapper->snapshotsDir() + "/" + decString(num)).c_str(), 0777);
+ int r;
+ while ((r = mkdir((snapper->snapshotsDir() + "/" + decString(num)).c_str(), 0777)) == -1 &&
+ errno == EEXIST)
+ ++num;
- // TODO check EEXIST
+ if (r != 0)
+ throw IOErrorException();
return num;
}