Odd Error with Readstream...
BlitzMax Forums/BlitzMax Programming/Odd Error with Readstream...
| ||
Can anyone see why this would fail to check for the existence of a named file ? Im not do an excessive amount of loading - randomly it errors with cant not find...... Function Check(file:String) Local thisStream:TStream = ReadStream(file) If Not ReadStream(file) Then RuntimeError("Can not find " + String(file)) End EndIf thisstream.Close End Function |
| ||
If you want to check if a file exists:Function FileExist:int(File:String) If FileSize(File) = -1 Then Return False Return true End Function A ReadStream will create the file. |
| ||
Possibly im using readstream twice instead of once ? I've changed it to check for a null stream instead...Function Check(file:String) Local thisStream:TStream = ReadStream(file) If thisStream = Null Then RuntimeError("Can not find " + String(file)) End EndIf thisstream.Close End Function |
| ||
Possibly should useIf FileType(file) <> 1 That way, it'll post the error if the file doesn't exist or it is a directory instead of a readable file. |
| ||
IM not actually using a file, its from a stream so filetype wont work. |