| 393 | } |
| 394 | |
| 395 | int SaveFile::closeFile() |
| 396 | { |
| 397 | if (closed) { |
| 398 | errno = EBADF; |
| 399 | return -1; |
| 400 | } |
| 401 | |
| 402 | closed = true; |
| 403 | |
| 404 | /* If the file wasn't removed, do nothing */ |
| 405 | if (!removed) |
| 406 | return 0; |
| 407 | |
| 408 | if (stream) { |
| 409 | NATIVECALL(fclose(stream)); // closes both the stream and fd |
| 410 | stream = nullptr; |
| 411 | fd = 0; |
| 412 | } |
| 413 | else if (fd != 0) { |
| 414 | NATIVECALL(close(fd)); |
| 415 | fd = 0; |
| 416 | } |
| 417 | |
| 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | int SaveFile::remove() |
| 422 | { |
no test coverage detected