Page 1 of 1

FileSize does not return -2 for existing linked subdirectory

Posted: Thu Oct 16, 2014 11:50 pm
by Froggerprogger
(Windows 7 32bit, PureBasic 5.30)

Problem: FileSize returns -1 (not existing) for an existing directory that is below a directory link.

Example: "C:\Program Files\" is a directory, and in German Windows versions there is a link to it called "C:\Programme\".

FileSize returns -2 for both of them (as it should).
However, it does not return -2 for subdirectories if they are accessed via the link, see the example:

Code: Select all

p1$ = "C:\Program Files\PureBasic"
p2$ = "C:\Programme\PureBasic"

Debug PathIsDirectory_(p1$) ; gives 16 (correct)
Debug FileSize(p1$) ; gives -2 (correct)

Debug PathIsDirectory_(p2$) ; gives 16 (correct)
Debug FileSize(p2$)         ; gives -1 (FAIL... should be -2)
This gave a weird behaviour of my installer program, which claimed that the program directory could not be created - although it already existed :)

Workaroud: Use PathIsDirectory_ instead.

EDIT:
Updating Windows fixed this for me (see explanations below).

Re: FileSize does not return -2 for existing linked subdirec

Posted: Fri Oct 17, 2014 12:46 am
by Thunder93
Hi.

I've manually added this SymLink because I'm using non-German Windows version.

I'm seeing the results your are expecting to see...

If you entered the following into the Run dialog and submitted, does it launch Explorer to the destination folder without erroring? C:\Programme

Re: FileSize does not return -2 for existing linked subdirec

Posted: Fri Oct 17, 2014 9:01 am
by Froggerprogger
If I enter "C:\Programme" into the run dialog then an error message pops up, although "C:\Program Files" works. But everywhere else "C:\Programme" works.

Thank you for this hint! Now I found [1] where they discuss that this is a bug-or-something-similar in Windows Vista and Windows 7 that only affects the German version. I suppose that it was related to the fact that "SHGetFolderLocation_" for CSIDL_PROGRAM_FILES returned "C:\Programme", not "C:\Program Files". However, while typing this answer, my stupid Windows rebooted due to some updates (so I lost my first text entirely...). The good news: Now "SHGetFolderLocation_" returns "C:\Program Files", so my installer program now prefills the form with a directory location that works...

So the short answer: The problem removes after installing all Windows updates.

(this was a fresh Windows 7 in a Virtual Box under Ubuntu, and I am really happy when I can leave it back to Linux :twisted: )

[1] http://answers.microsoft.com/de-de/wind ... 717?auth=1