boost::filesystem::perms on Windows

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

boost::filesystem::perms on Windows

Boost - Users mailing list
Hi. I'm not having any luck with finding out whether a folder is writable or not,
on Windows. Is Boost.Filesystem (1.64) supposed to work on Windows for permissions?
Especially in "special" folders like those in "C:\Program Files"?

C:\Program Files\Vendor\App>echo foo > bar
Access is denied.

But Boost.Filesystem reports permissions as rw-rw-rw-, when printing
them using the BFS-equivalent to the example available on CppReference 

Despite obviously the folder not being writable, w/o being an administrator.
I'm naively using simple code like below:
```
fs::path path(name);
fs::file_status stat = fs::status(path);
fs::perms p = stat.permissions();
demo_perms(p);
```
Am I missing something obvious? Thanks, --DD

PS: I worked around the above, actually trying to create a file,
  but that has corner cases too, and I'd much prefer a reliable and cross-platform
  .permissions() from Boost. Smoothing-over platform differences is one "raison d'etre"
  from Boost after all, no?

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::filesystem::perms on Windows

Boost - Users mailing list
On 7/05/2020 03:45, Dominique Devienne wrote:

> Hi. I'm not having any luck with finding out whether a folder is
> writable or not,
> on Windows. Is Boost.Filesystem (1.64) supposed to work on Windows for
> permissions?
> Especially in "special" folders like those in "C:\Program Files"?
>
> C:\Program Files\Vendor\App>echo foo > bar
> Access is denied.
>
> But Boost.Filesystem reports permissions as rw-rw-rw-, when printing
> them using the BFS-equivalent to the example available on CppReference
> https://en.cppreference.com/w/cpp/filesystem/perms
>
> Despite obviously the folder not being writable, w/o being an administrator.

IIRC, it only looks at the basic file attributes (in this case, the
"read only" checkbox), and doesn't check the ACL at all.

I think it ignores ACLs on Unixen similarly (albeit they're less
commonly used over there).
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::filesystem::perms on Windows

Boost - Users mailing list
On Thu, May 7, 2020 at 12:54 AM Gavin Lambert via Boost-users <[hidden email]> wrote:
On 7/05/2020 03:45, Dominique Devienne wrote:
> Hi. I'm not having any luck with finding out whether a folder is  writable or not,

IIRC, it only looks at the basic file attributes (in this case, the
"read only" checkbox), and doesn't check the ACL at all.

Thanks Gavin.

OK. Disappointing, but I get it. I'll soon be able to use C++17, so I'll give the
std::filesystem version a try, to see if it can get it right, since implemented by
Microsoft itself this time. We'll see. --DD

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users