It seems I can't get File.Read(blob) or blob=File.Read(size) to work.
This doesn't seem to work:
var b=DOpus.NewBlob(5000);
var f=DOpus.FSUtil.OpenFile("D:\\tmp\\x\\account_actions_24.jpg","we");
if ((f)&&(f.error==0)){
f.Seek(0,"b");
f.Read(b,1059);
f.Close();
}
I've also tried f.Read(b).
The error for both is "A method was called unexpectedly (0x8000ffff)" when calling f.Read.
I found this while experimenting with reading the width/height myself using js..which probably should
be possible after file and blob was added.
Ah, thats why.. I found it strange that all the items listed began with w, but I didn't really think much of it.
No wonder then.
The error could've been handled better though, such as by providing some errorcode in .error or something other
than a E_UNEXPECTED/unhandled exception.
At the point you test f.error, no error has occurred.
When you call Read on a write-only file, the Read call is unexpected, so E_UNEXPECTED makes sense. I'm not sure Win32 defines a more suitable error code for that situation. (Win32 wastes so many error codes on incredibly specific/esoteric meanings/messages, and leaves out some very common/generic cases. It's a pain.)
Obviously.. I meant when the error occured.
Yes I know the errorcodes aren't really that usable (by experience), but I'd assume that anything is better than a unhandled exception/catastrophic failure.
E_UNEXPECTED isn't that kind of unexpected, but more like "sorry, I can't deal with this and I don't know why..but it is a fatal/catastrophic failure."
I guess it is among the most severe messages available.
But it's an error that will happen every time the script runs. There's no point allowing the script to handle the error better since it's not a transitory thing that might work next time. It may as well abort so you can fix it.
I have no problem with aborting, although it seems win32 has an error for this situation.
I tried opening a file only for reading (in C), then did a ReadFile on it which caused no data to be read
and GetLastError returns 5 (ERROR_ACCESS_DENIED)..which kind of makes sense.