fopen & Vista64(32)

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

fopen & Vista64(32)

Post by Desperado »

Hello everyone,

i simply dont know why fopen doesnt work proper on vista.
Outside my working folders fopen fails, when i want
to create a file.

of course it may depend on read/write access, and i played
around with it. But nothing helps so far.

Help needed, thx :(

Michael
humble_programmer

Re: fopen & Vista64(32)

Post by humble_programmer »

You might try using fopen_s() instead: it supposedly provides better security (?) but more importantly, it also returns an error code that should show the difference between a missing file versus a file you don't have read/write permissions to. If that fails, you might also consider using the Win32 CreateFile() API call, which would at least remove any interference caused by the RTL.

I would also respectfully suggest that you move this type of question to a more appropriate forum, such as www.codeproject.com or www.codeguru.com.
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: fopen & Vista64(32)

Post by UncombedCoconut »

humble_programmer wrote:You might try using fopen_s() instead: it supposedly provides better security (?) but more importantly, it also returns an error code that should show the difference between a missing file versus a file you don't have read/write permissions to. If that fails, you might also consider using the Win32 CreateFile() API call, which would at least remove any interference caused by the RTL.
I'd disagree with this, unless the program is intended to be Windows-only forever. fopen_s() is non-standard and provides dubious benefits; after an ordinary fopen(), you can already get the error code by checking errno.
I would also respectfully suggest that you move this type of question to a more appropriate forum, such as www.codeproject.com or www.codeguru.com.
This is a fair suggestion though.
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: fopen & Vista64(32)

Post by Desperado »

First, thx for reply.

www.msdn.microsoft.com/en-us/library/ee419001

Looks like i will find the solution here.

ohhh my god :shock:

michael
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: fopen & Vista64(32)

Post by Desperado »

UncombedCoconut wrote:
I would also respectfully suggest that you move this type of question to a more appropriate forum, such as www.codeproject.com or www.codeguru.com.
This is a fair suggestion though.
ps: of course i browsed the web on this more general problem for
hints first.

but my second thought was, that nearly each free chess-engine source i looked at,
was using somewhere fopen for creating debug,statistic outputs.
So someone should know what is going on with vista ? (so i thought it is a good place to ask for it. :roll: )

michael
Christopher Conkie
Posts: 6073
Joined: Sat Apr 01, 2006 9:34 pm
Location: Scotland

Re: fopen & Vista64(32)

Post by Christopher Conkie »

Desperado wrote:First, thx for reply.

www.msdn.microsoft.com/en-us/library/ee419001

Looks like i will find the solution here.

ohhh my god :shock:

michael
Most fopen() issues are related to permissions on Vista and Windows 7. The user that creates the file needs permission to create it in the directory where you create it.

To me if you gave you (ie who you are logged on as and it does not matter if Administrator has it) full control of the directory, you should cure the problem. Failing that create the file where you know Everyone has full control.

I have seen this problem before with IIS and PHP on Vista and Windows 7 x64 where it becomes very tricky as you should not give chmod 777 to anywhere.

Hope this helps a little.

Christopher