changing code for making directory baseline in order to comply with mingw
parent
691af085cd
commit
39978f905f
|
@ -4289,24 +4289,29 @@ DynamicModel::isChecksumMatching(const string &basename) const
|
|||
result.process_bytes(private_buffer,strlen(private_buffer));
|
||||
}
|
||||
|
||||
bool basename_dir_exists = false;
|
||||
#ifdef _WIN32
|
||||
int r = mkdir(basename.c_str());
|
||||
#else
|
||||
int r = mkdir(basename.c_str(), 0777);
|
||||
#endif
|
||||
if (r < 0)
|
||||
if (errno != EEXIST)
|
||||
{
|
||||
perror("ERROR");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else
|
||||
basename_dir_exists = true;
|
||||
|
||||
// check whether basename directory exist. If not, create it.
|
||||
// If it does, read old checksum if it exist
|
||||
fstream checksum_file;
|
||||
string filename = basename + "/checksum";
|
||||
unsigned int old_checksum = 0;
|
||||
struct stat sd;
|
||||
if (stat(basename.c_str(), &sd) != 0)
|
||||
// read old checksum if it exists
|
||||
if (basename_dir_exists)
|
||||
{
|
||||
const int dir_err = mkdir(basename.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
if (dir_err == -1)
|
||||
{
|
||||
cerr << "ERROR: can't create directory " << basename << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// read old checksum if it exists
|
||||
checksum_file.open(filename.c_str(), ios::in | ios::binary);
|
||||
if (checksum_file.is_open())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue