X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/7a6e17cff79a3a007a2519bdb676f1be8e937624..e7783492d5df3db416020d9a4aa5c36222f17ef4:/Cytore.hpp diff --git a/Cytore.hpp b/Cytore.hpp index a382dd87..c0bad09b 100644 --- a/Cytore.hpp +++ b/Cytore.hpp @@ -178,7 +178,7 @@ class File { return blocks_.size() * Block_; } - void Open(const char *path) { + void Open(const char *path) { open: _assert(file_ == -1); file_ = open(path, O_RDWR | O_CREAT | O_EXLOCK, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); _assert(file_ != -1); @@ -197,8 +197,12 @@ class File { Header_().magic_ = Magic; Size_() = core; + } else if (size < core) { + close(file_); + file_ = -1; + unlink(path); + goto open; } else { - _assert(size >= core); // XXX: this involves an unneccessary call to ftruncate() _assert(Truncate_(size)); _assert(Header_().magic_ == Magic);