mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Style cleanup.
This commit is contained in:
parent
4c01e4e159
commit
04cca33094
4 changed files with 20 additions and 23 deletions
|
|
@ -30,25 +30,24 @@ fs::path FlatFileSeq::FileName(const FlatFilePos& pos) const
|
|||
return m_dir / strprintf("%s%05u.dat", m_prefix, pos.nFile);
|
||||
}
|
||||
|
||||
FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool fReadOnly)
|
||||
FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool read_only)
|
||||
{
|
||||
if (pos.IsNull())
|
||||
if (pos.IsNull()) {
|
||||
return nullptr;
|
||||
}
|
||||
fs::path path = FileName(pos);
|
||||
fs::create_directories(path.parent_path());
|
||||
FILE* file = fsbridge::fopen(path, fReadOnly ? "rb": "rb+");
|
||||
if (!file && !fReadOnly)
|
||||
FILE* file = fsbridge::fopen(path, read_only ? "rb": "rb+");
|
||||
if (!file && !read_only)
|
||||
file = fsbridge::fopen(path, "wb+");
|
||||
if (!file) {
|
||||
LogPrintf("Unable to open file %s\n", path.string());
|
||||
return nullptr;
|
||||
}
|
||||
if (pos.nPos) {
|
||||
if (fseek(file, pos.nPos, SEEK_SET)) {
|
||||
LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, path.string());
|
||||
fclose(file);
|
||||
return nullptr;
|
||||
}
|
||||
if (pos.nPos && fseek(file, pos.nPos, SEEK_SET)) {
|
||||
LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, path.string());
|
||||
fclose(file);
|
||||
return nullptr;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue