Opened 13 years ago

#3949 new Feature Requests

filesystem::rename() "does not exist" check is sometimes unwanted

Reported by: Paul Pogonyshev <pogonyshev@…> Owned by: Beman Dawes
Milestone: Boost 1.43.0 Component: filesystem
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

POSIX allows to rename/move a file over another, unlike Windows. Currently, Boost (according to source code) explicitly adds a check against this, using an exists() call. However, sometimes POSIX behavior is desired, to avoid extra remove() call.

Moreover, since exist()/remove()/rename() is inherently non-atomic (as are all filesystem operation), this unnecessarily (on POSIX) creates another race-condition point.

Request: change rename prototype to rename(from, to, overwrite = false) and adjust code accordingly. If 'overwrite' is false (default) it will work just as now, so the change is fully backward-compatible. If overwrite is 'true', POSIX implementation will just omit its exist() check, while Windows implementation will call remove(to) and catch errors.

Change History (0)

Note: See TracTickets for help on using tickets.