Home » U++ Library support » U++ Core » simple bug? passing String::GetVoid() to StringStream
simple bug? passing String::GetVoid() to StringStream [message #49770] |
Sat, 28 April 2018 12:06 |
luoganda
Messages: 194 Registered: November 2016
|
Experienced Member |
|
|
is this a bug? if is, this is for any Stream based class
If fname does not exist(down code), LoadFile ret String::GetVoid(), then pass this to StringStream constructor,
but ss.IsError() and ss.IsOpen doesn't react on it(doesn't take into consideration that String::GetVoid() was passed.
StringStream ss(LoadFile(fname));if(ss.IsError()){errline("Can't load file %s",~fname);return false;}
Of course, this can easily be solved by checking if FileExists before passing it to StringStream
|
|
|
Re: simple bug? passing String::GetVoid() to StringStream [message #49772 is a reply to message #49770] |
Sun, 29 April 2018 19:52 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
luoganda wrote on Sat, 28 April 2018 12:06is this a bug? if is, this is for any Stream based class
If fname does not exist(down code), LoadFile ret String::GetVoid(), then pass this to StringStream constructor,
but ss.IsError() and ss.IsOpen doesn't react on it(doesn't take into consideration that String::GetVoid() was passed.
StringStream ss(LoadFile(fname));if(ss.IsError()){errline("Can't load file %s",~fname);return false;}
Of course, this can easily be solved by checking if FileExists before passing it to StringStream
Well, it is not a bug, although your reasoning has a logic in it.
Anyway, for all purposes GetVoid is considered equal to empty string, with the only difference being that you can test for IsVoid. So it was meant to be used as this:
String data = LoadFile(fname);
if(data.IsVoid()) {
errline("...");
return false;
}
StringString ss(data);
|
|
|
Goto Forum:
Current Time: Thu Apr 25 19:33:27 CEST 2024
Total time taken to generate the page: 0.05272 seconds
|