From: Gernot Frisch on
Hi,

when I try to do:
FindFirstFile(_T("C:\\Users\\gf\\Anwendungsdaten\\*.*", &fnd)
it returns NULL (Last error yields "access denied").

"C:\Users\gf\Anwendungsdaten" is a reparse point targeting "C:\Users\gf\Roaming".

OK, I can find the target and all. Fine.

BUT!!!
FindFirstFile(_T("C:\\Users\\gf\\Anwendungsdaten\\Adobe\\*.*", &fnd)

works perfeclty and it's no reparse point, although it is accessed trough such.

My code works flawlessly, but I'm a bit unsure if this behaviour is correct now.

Thank you for sheding light.

--
------------------------------------
Gernot Frisch
http://www.glbasic.com

From: Dee Earley on
On 13/07/2010 15:24, Gernot Frisch wrote:
> Hi,
>
> when I try to do:
> FindFirstFile(_T("C:\\Users\\gf\\Anwendungsdaten\\*.*", &fnd)
> it returns NULL (Last error yields "access denied").
>
> "C:\Users\gf\Anwendungsdaten" is a reparse point targeting
> "C:\Users\gf\Roaming".
>
> OK, I can find the target and all. Fine.
>
> BUT!!!
> FindFirstFile(_T("C:\\Users\\gf\\Anwendungsdaten\\Adobe\\*.*", &fnd)
>
> works perfeclty and it's no reparse point, although it is accessed
> trough such.
>
> My code works flawlessly, but I'm a bit unsure if this behaviour is
> correct now.
>
> Thank you for sheding light.

That is "correct" and the same way explorer behaves.
Access is denied to listing sub folders, but you can access those
subfolders by name for compatibility.

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
From: Leo Davidson on
On Jul 13, 3:24 pm, "Gernot Frisch" <m...(a)privacy.net> wrote:

> when I try to do:
> FindFirstFile(_T("C:\\Users\\gf\\Anwendungsdaten\\*.*", &fnd)
> it returns NULL (Last error yields "access denied").
>
> "C:\Users\gf\Anwendungsdaten" is a reparse point targeting "C:\Users\gf\Roaming".


Those reparse points exist for compatibility with programs which use
hard-coded paths instead of asking the OS for the appropriate paths
via an API.

They deny access to listings at their top level on purpose in order to
block tools which don't know any better from recursing into them.
(e.g. A naive backup tool which does not understand reparse points may
store two copies of the same data, then later restore two separate
copies which then go out of sync with each other.)

The error you are seeing is not because of reparse points; it's
because of how those particular reparse points are permissioned. (It's
possible to create reparse points which don't deny list access to
their top level, just as it's possible to create normal folders which
deny access.)

If you want to find files in the user's AppData folder, you should ask
the OS for the correct path to it. (Even if you're not running as that
user, there is an API which you can give a username to and the OS will
return the correct path.)

On the other hand, if you need to be able to handle those legacy paths
(e.g. because they are passed to you by something else) and you know
that it makes sense to recurse into them, then you can detect that the
path given to you is a reparse points, lookup the path it points to
and then perform your operation on that path instead of the original.
From: Gernot Frisch on

>> "C:\Users\gf\Anwendungsdaten" is a reparse point targeting "C:\Users\gf\Roaming".

> you should ask the OS for the correct path to it.

The problem I had was with a self-written file explorer dialog. It displayed these legacy folders, but was unable to iterate
into them.
I think I'll leave the code as is now.


From: Ulrich Eckhardt on
Gernot Frisch wrote:
>
>>> "C:\Users\gf\Anwendungsdaten" is a reparse point targeting
>>> "C:\Users\gf\Roaming".
>
>> you should ask the OS for the correct path to it.
>
> The problem I had was with a self-written file explorer dialog. It
> displayed these legacy folders, but was unable to iterate into them.
> I think I'll leave the code as is now.

For iterating, you have to use GetFileAttributes() anyway to distinguish
between directory and file, and there you also have a bit for reparse
points. The only thing you need to do is to read the reparse point's
content.

Uli


--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932