From: Beman Dawes (bdawes_at_[hidden])
Date: 2003-06-22 11:38:05
At 08:02 AM 6/22/2003, John Maddock wrote:
>I'm having a problem with the filesystem lib and read only files -
>if I copy a read only file then the result is read only, fair enough.
>However if I then try and overwrite that file with another file copy it
>throws because of the read only status of the target file, still fair
>enough. So then I try and remove the target file with remove first, but
>that throws as well because the file "not accessible" i.e. read only! So
>how can I get rid of a read only file? At present it seems to be
Yes, at the moment it is impossible with the filesystem library.
[Warning: half-baked ideas follows. I don't even know if it is spelled
writeable or writable.]
If we can figure out portable behavior that will work on POSIX and Windows,
and is likely safe if not useful on other operating systems, then perhaps
we should add something to <boost/filesystem/operations.hpp> like:
bool is_writeable( const path & );
On Windows, the return would reflect the state of the read-only attribute
On POSIX, the return would reflect the Write permission bit for the most
restrictive user class which applies.
On O/S's which have no concept which usefully maps into is_writeable,
Note that a true return from is_writeable() does not guarantee that a file
or directory can actually be written to by the program.
void set_writeable( const path &, bool value = true );
On Windows, would set the read-only attribute bit accordingly. May throw.
On POSIX, would set the write permission bit for the most restrictive user
class which applies. May throw.
On O/S's which have no concept of is_writeable, has no effect. Does not
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk