You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The w mode for files should allow existing files to be overwritten when creating a new file. However, that doesn't appear to be respected.
I'm creating filesystem-based files. In z5::handle::File, the create() method has a couple checks before creating the file:
inline void create() const {
if(!mode().canCreate()) {
const std::string err = "Cannot create new file in file mode " + mode().printMode();
throw std::invalid_argument(err.c_str());
}
if(exists()) {
throw std::invalid_argument("Creating new file failed because it already exists.");
}
createDir();
}
The first check guarantees the file is a writeable file, and that looks fine. The second check guarantees that the file doesn't already exist. This if statement doesn't respect the w mode and treats all writeable files as if they're w_m or a mode files.
A possible solution would be to add an inner check:
if(exists()) {
if(mode().shouldTruncate()) {
[remove existing file]
} else {
throw std::invalid_argument("Creating new file failed because it already exists.");
}
}
The text was updated successfully, but these errors were encountered:
The
w
mode for files should allow existing files to be overwritten when creating a new file. However, that doesn't appear to be respected.I'm creating filesystem-based files. In
z5::handle::File
, thecreate()
method has a couple checks before creating the file:The first check guarantees the file is a writeable file, and that looks fine. The second check guarantees that the file doesn't already exist. This if statement doesn't respect the
w
mode and treats all writeable files as if they'rew_m
ora
mode files.A possible solution would be to add an inner check:
The text was updated successfully, but these errors were encountered: