scope file.open
nobody
not at possible.de
Tue Jan 23 07:12:54 PST 2007
Hallo,
how can i saftly open a file with scope.
My idea is:
import std.stream;
import std.stdio;
void main() {
File file = new File;
scope(failure) {
writefln("Datei kann nicht geoeffnet werden ");
}
file.open("testdatei.txt",FileMode.In);
while(!file.eof()) {
printf("%.*s\n",file.readLine());
}
file.close();
}
But why must scope(failure) before the file.open statement.
I think it's look strange.
Mybe some on have a better idea to open a file with scope.
Sincerily
More information about the Digitalmars-d-learn
mailing list