refuses to open file
Ali Çehreli
acehreli at yahoo.com
Wed Apr 17 15:16:44 PDT 2013
On 04/17/2013 02:57 PM, rbtwms at digitalpath.net wrote:
> I had made so many changes truing to solve the problem that I included a
> older version. another problem is that with the file name: efile =
> File("l:\\filepro\\mvmammach\\key") with no space before the drive letter
> the silently quits with no error but as you can see efile name is
just a hex
> number.(see (1)) putting a space before the drive letter causes the
> exception (see (2)).
>
>
> (1)
> command line ["eqipfile"]
> defile name is File(2002FE0)
Is it really "defile" that gets printed up there, or is that another
typo? I highly recommend that you provide a complete program for us to try.
> WITHOUT SPACE!
>
> (2)
> command line ["eqipfile"]
> std.exception.ErrnoException at std\stdio.d(289): Cannot open file `
> l:\filepro\mvammach\key ' in mode `rb' (Invalid argument)
This time it seems to be complaining about a space *after* the file
name! (?)
> ----------------
> 0x0041B478
> 0x0041B303
> 0x004101E3
> 0x0040BB04
> 0x0040BB3E
> 0x0040B760
> 0x00422AED
> 0x770133AA in BaseThreadInitThunk
> 0x77DB9EF2 in RtlInitializeExceptionChain
> 0x77DB9EC5 in RtlInitializeExceptionChain
>
>
> WITH SPACE!
>
> code excerpt follows:
>
> writefln("command line %s", args[]);
> efile = File(" l:\\filepro\\mvammach\\key");
I have a vague recollection that forward slashes work with file names
even under Windows.
> writefln("efile name is %s", efile);
> char[4600] buf;
That doesn't look right: char is a UTF-8 code unit. Unless you are sure
that the file contains UTF-8, I recommend you use something else, e.g.
ubyte.
> string[int] list;
> efile.rawRead(buf);
Do you intend to ignore that read? The data will be overwritten by the
following rawRead.
> while(efile.rawRead(buf)){
> if(buf[0] != 0x01) continue;
> string c = to!string (buf[107..111]);
You are doing that because you are sure that there is a valid Unicode
character there? (Although I am not sure how it is related to the problem.)
> if (c == " ") break;
> int z = to!int(c);
> string s = to!string(buf[67..92]);
'to' may throw an exception. Try wrapping that section in a try block to
see whether you get any information from that exception.
Also, try compiling with -g or -gc to see whether the backtrace will be
more useful.
> list[z] = s;
> }
> Sorry I seen to have had my identity set up wrong it is corrected now.
Ali
More information about the Digitalmars-d-learn
mailing list