Re: [boost] Filesystem problem

2003-06-23 Thread John Maddock

> Comments?

Sounds reasonably to me, but I admit that I don't really understand POSIX
filesystems.  I guess what I really wanted was something that would be
equivalent to "rm -f file", remember that we already have the equivalent to
"rm -r path".  Of course I don't know how one would implement that :-)

John.


___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Re: [boost] Filesystem problem

2003-06-22 Thread Zsolt Rizsanyi
On Sunday 22 June 2003 14.02, John Maddock wrote:
> Beman,
>
> I'm having a problem with the filesystem lib and read only files -
> basically 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
> impossible?

The deletion of a file should depend on permissions of the directory and not 
of the file!
That way if you could write the file (you have write permissions on the dir), 
then you can delete it, regardless of the permissions of the file.

That's how it works on *nix.
So IMHO this is the bug in the filesystem lib.
(Note: I did not check the filesystem lib code, nor do I use it. But I have 
read the lib documentation :)

Regards
Zsolt

___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Re: [boost] Filesystem problem

2003-06-22 Thread Beman Dawes
At 08:02 AM 6/22/2003, John Maddock wrote:

>I'm having a problem with the filesystem lib and read only files -
>basically
>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
>impossible?

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  like:

   bool is_writeable( const path & );

On Windows, the return would reflect the state of the read-only attribute 
bit.

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, 
return true.

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 
throw.

Comments?

--Beman

___
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost