Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 21, 2004 std.stream | ||||
---|---|---|---|---|
| ||||
Hi all, What is the best 'D' way for opening a file with std.stream readonly but raise an exception and NOT to create it if it does not exists? --- Paolo Invernizzi |
July 21, 2004 Re: std.stream | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paolo Invernizzi | In article <cdlkh2$2jn2$1@digitaldaemon.com>, Paolo Invernizzi says... > >Hi all, > >What is the best 'D' way for opening a file with std.stream readonly but raise an exception and NOT to create it if it does not exists? I don't know of any way of doing this /atomically/ on Windows. (It might work on Linux - can't say as I don't use it). This is a bug which has been mentioned before on this forum, but so far no-one's said anything about fixing it. (Possibly because this is not the bugs forum). My workaround - don't use std.stream unless you KNOW the file already exists. Good old fopen() will do the job just fine - OK, so it's not OO and doesn't throw exceptions and so on, but hopefully it's just a temporary workaround until someone in Phobos realizes that READ access should not CREATE, and does something about it. Arcane Jill |
July 21, 2004 Re: std.stream | ||||
---|---|---|---|---|
| ||||
Posted in reply to Arcane Jill | see my reply to the bug report on digitalmars.d.bugs for the fix to phobos. "Arcane Jill" <Arcane_member@pathlink.com> wrote in message news:cdllva$2khp$1@digitaldaemon.com... > In article <cdlkh2$2jn2$1@digitaldaemon.com>, Paolo Invernizzi says... > > > >Hi all, > > > >What is the best 'D' way for opening a file with std.stream readonly but raise an exception and NOT to create it if it does not exists? > > I don't know of any way of doing this /atomically/ on Windows. (It might work on > Linux - can't say as I don't use it). > > This is a bug which has been mentioned before on this forum, but so far no-one's > said anything about fixing it. (Possibly because this is not the bugs forum). > > My workaround - don't use std.stream unless you KNOW the file already exists. > Good old fopen() will do the job just fine - OK, so it's not OO and doesn't > throw exceptions and so on, but hopefully it's just a temporary workaround until > someone in Phobos realizes that READ access should not CREATE, and does something about it. > > Arcane Jill > > > > |
July 21, 2004 Re: std.stream | ||||
---|---|---|---|---|
| ||||
Posted in reply to Arcane Jill | Arcane Jill wrote:
> In article <cdlkh2$2jn2$1@digitaldaemon.com>, Paolo Invernizzi says...
>
>>Hi all,
>>
>>What is the best 'D' way for opening a file with std.stream readonly but raise an exception and NOT to create it if it does not exists?
>
>
> I don't know of any way of doing this /atomically/ on Windows. (It might work on
> Linux - can't say as I don't use it).
>
> This is a bug which has been mentioned before on this forum, but so far no-one's
> said anything about fixing it. (Possibly because this is not the bugs forum).
There is a way to fix this. In fact I've already fixed it in my (much delayed) stream updates. I'm still bogged down with readf but when that's done I'll finish up the stream stuff.
Sean
|
July 21, 2004 Re: std.stream | ||||
---|---|---|---|---|
| ||||
Posted in reply to Arcane Jill | Arcane Jill wrote: > This is a bug which has been mentioned before on this forum, but so far no-one's > said anything about fixing it. (Possibly because this is not the bugs forum). I was no sure it was a bug ;-) > My workaround - don't use std.stream unless you KNOW the file already exists. > Good old fopen() will do the job just fine - OK, so it's not OO and doesn't > throw exceptions and so on, but hopefully it's just a temporary workaround until > someone in Phobos realizes that READ access should not CREATE, and does > something about it. Ok... --- Paolo Invernizzi |
Copyright © 1999-2021 by the D Language Foundation