MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / open

Method open

src/Core/src/FileStream.cpp:91–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 8

LogFileMethod · 0.80
Config.cppFile · 0.80
saveIndexFunction · 0.80
tryLoadIndexFunction · 0.80
saveIndexFunction · 0.80
addObjectToIndexFunction · 0.80
tryLoadIndexFunction · 0.80
run_clang_format_diffFunction · 0.80

Calls 3

fileOpenFunction · 0.85
getFileLengthFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected