| 89 | } |
| 90 | |
| 91 | bool FileStream::open(const std::filesystem::path& path, StreamMode mode) |
| 92 | { |
| 93 | close(); |
| 94 | |
| 95 | _file = fileOpen(path, mode); |
| 96 | if (_file == nullptr) |
| 97 | { |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | // Increase the buffer size to 1MiB. |
| 102 | std::setvbuf(_file, nullptr, _IOFBF, 1024 * 1024); |
| 103 | |
| 104 | // Get the length if we are reading an existing file. |
| 105 | if (mode == StreamMode::read) |
| 106 | { |
| 107 | _length = getFileLength(_file); |
| 108 | } |
| 109 | |
| 110 | _offset = 0; |
| 111 | _mode = mode; |
| 112 | return true; |
| 113 | } |
| 114 | |
| 115 | bool FileStream::isOpen() const noexcept |
| 116 | { |
no test coverage detected