Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
detect attempts to overwrite input data #842
As discussed on this community forum thread.
I don't think there's any simple portable way of querying whether a file we've just opened read-write was already being accessed read-only - that would be the ideal scenario. But I do think we can keep track of this ourselves relatively easily, since 99% of file access will be via the
This should sort out most issues with trying to write to one of our inputs, although there will still need to be some changes to some of the image formats that open the file using C++ IO streams (e.g. the MRtrix formats), since it's basically impossible to retrieve the associated fd from that - at least not in a portable way (see this page to get an idea of how complicated that might turn out to be...). The simplest thing to do in these cases will be to enforce that all file access is done via standard C calls that operate on file descriptors (not even
An alternative approach which might actually work more seamlessly is to rely on the device ID & inode number for the file as retrieved via the
So not trivial, but potentially doable...