FileSize does not return -2 for existing linked subdirectory

Windows specific forum
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

FileSize does not return -2 for existing linked subdirectory

Post 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).
Last edited by Froggerprogger on Fri Oct 17, 2014 9:08 am, edited 1 time in total.
%1>>1+1*1/1-1!1|1&1<<$1=1
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

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

Post 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
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

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

Post 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
%1>>1+1*1/1-1!1|1&1<<$1=1
Post Reply