mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Throwing exceptions with text after copy file check failure and renaming from .tmp failure
This commit is contained in:
parent
5e91bcc91c
commit
93f9fc1049
2 changed files with 21 additions and 6 deletions
|
@ -449,7 +449,7 @@ int copy_file(const std::string &from, const std::string &to, const bool with_ch
|
|||
ret_val = check_copy(from, to_temp);
|
||||
|
||||
if (ret_val == 0 && rename_file(to_temp, to))
|
||||
ret_val = -1;
|
||||
ret_val = -3;
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
|
@ -460,11 +460,11 @@ int check_copy(const std::string &origin, const std::string ©)
|
|||
std::ifstream f2(copy, std::ifstream::in | std::ifstream::binary | std::ifstream::ate);
|
||||
|
||||
if (f1.fail() || f2.fail())
|
||||
return -1;
|
||||
return -2;
|
||||
|
||||
std::streampos fsize = f1.tellg();
|
||||
if (fsize != f2.tellg())
|
||||
return -1;
|
||||
return -2;
|
||||
|
||||
f1.seekg(0, std::ifstream::beg);
|
||||
f2.seekg(0, std::ifstream::beg);
|
||||
|
@ -481,12 +481,12 @@ int check_copy(const std::string &origin, const std::string ©)
|
|||
if (origin_cnt != copy_cnt ||
|
||||
(origin_cnt > 0 && std::memcmp(buffer_origin.data(), buffer_copy.data(), origin_cnt) != 0))
|
||||
// Files are different.
|
||||
return -1;
|
||||
return -2;
|
||||
fsize -= origin_cnt;
|
||||
} while (f1.good() && f2.good());
|
||||
|
||||
// All data has been read and compared equal.
|
||||
return (f1.eof() && f2.eof() && fsize == 0) ? 0 : -1;
|
||||
return (f1.eof() && f2.eof() && fsize == 0) ? 0 : -2;
|
||||
}
|
||||
|
||||
// Ignore system and hidden files, which may be created by the DropBox synchronisation process.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue