mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-21 15:00:06 +00:00
Minor os.read() fixes
This commit is contained in:
parent
cfb4df66f9
commit
24bbc22cd4
@ -256,6 +256,11 @@ int cosmoB_osRead(CState *state, int nargs, CValue *args) {
|
||||
char *buf;
|
||||
size_t size, bRead;
|
||||
|
||||
if (file == NULL) {
|
||||
// return nil, file doesn't exist
|
||||
return 0;
|
||||
}
|
||||
|
||||
// grab the size of the file
|
||||
fseek(file, 0L, SEEK_END);
|
||||
size = ftell(file);
|
||||
@ -266,8 +271,7 @@ int cosmoB_osRead(CState *state, int nargs, CValue *args) {
|
||||
|
||||
if (bRead < size) {
|
||||
// an error occured! we don't need to really throw an error, returning a nil is good enough
|
||||
cosmoV_pushNil(state);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf[bRead] = '\0'; // place the NULL terminator at the end of the buffer
|
||||
|
Loading…
Reference in New Issue
Block a user