Re: file access again
- Posted by coconut Dec 30, 2012
- 1191 views
My app does
writefile = open(writefilename,"ab") -- and open a new file
and i get a -1. The problem is that's wrong.
I can :
- open dosbox, type D:\ngrams\dbpedia\props3\A\Autism.txt -- prints to screen
- open dosbox, dir D:\ngrams\dbpedia\props3\A\Autism.txt -- prints data about
- open dosbox, edit D:\ngrams\dbpedia\props3\A\Autism.txt -- opens dos editor
- open Textpad, open and edit and save file -- performs properly
All jokes about autism and Aspergers aside, what is the malfunction here? When Eu returns -1 as writefile, there is no data to understand whatever it's problem is.
Pardon, but if I may be helpful...
there is no data to understand whatever its problem is.
(Normally, I don't care since these two sound the same, but since eukat has been so helpful in pointing out these issues in the past, I thought I'd return the favor at least just this once.)
In general, it's hard to say. If open() returns -1, that just means that fopen() returned NULL instead of a valid file handle.
On a nix system, you can check libc's errno value at this point to get more useful information (e.g. was it a permissions issue, low level i/o error reported from the driver, etc.) but I don't know if the relevant analogue applies on other platforms.
At first glance, this looks like it's happening on the same disk that had the strange errors and suspected disk corruption as referenced in http://openeuphoria.org/ticket/825.wc and http://openeuphoria.org/forum/m/119991.wc
Concerning windows there is 2 calls to get information about the last error. GetLastError() and FormatMessage() both are in kernel32.dll for an exemple refer to: http://msdn.microsoft.com/en-us/library/windows/desktop/ms680582(v=vs.85).aspx
Jacques