File tree Expand file tree Collapse file tree 4 files changed +20
-23
lines changed Expand file tree Collapse file tree 4 files changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -30,25 +30,24 @@ fs::path FlatFileSeq::FileName(const FlatFilePos& pos) const
30
30
return m_dir / strprintf (" %s%05u.dat" , m_prefix, pos.nFile );
31
31
}
32
32
33
- FILE* FlatFileSeq::Open (const FlatFilePos& pos, bool fReadOnly )
33
+ FILE* FlatFileSeq::Open (const FlatFilePos& pos, bool read_only )
34
34
{
35
- if (pos.IsNull ())
35
+ if (pos.IsNull ()) {
36
36
return nullptr ;
37
+ }
37
38
fs::path path = FileName (pos);
38
39
fs::create_directories (path.parent_path ());
39
- FILE* file = fsbridge::fopen (path, fReadOnly ? " rb" : " rb+" );
40
- if (!file && !fReadOnly )
40
+ FILE* file = fsbridge::fopen (path, read_only ? " rb" : " rb+" );
41
+ if (!file && !read_only )
41
42
file = fsbridge::fopen (path, " wb+" );
42
43
if (!file) {
43
44
LogPrintf (" Unable to open file %s\n " , path.string ());
44
45
return nullptr ;
45
46
}
46
- if (pos.nPos ) {
47
- if (fseek (file, pos.nPos , SEEK_SET)) {
48
- LogPrintf (" Unable to seek to position %u of %s\n " , pos.nPos , path.string ());
49
- fclose (file);
50
- return nullptr ;
51
- }
47
+ if (pos.nPos && fseek (file, pos.nPos , SEEK_SET)) {
48
+ LogPrintf (" Unable to seek to position %u of %s\n " , pos.nPos , path.string ());
49
+ fclose (file);
50
+ return nullptr ;
52
51
}
53
52
return file;
54
53
}
Original file line number Diff line number Diff line change @@ -24,14 +24,12 @@ struct FlatFilePos
24
24
READWRITE (VARINT (nPos));
25
25
}
26
26
27
- FlatFilePos () {
28
- SetNull ();
29
- }
27
+ FlatFilePos () : nFile(-1 ), nPos(0 ) {}
30
28
31
- FlatFilePos (int nFileIn, unsigned int nPosIn) {
32
- nFile = nFileIn;
33
- nPos = nPosIn;
34
- }
29
+ FlatFilePos (int nFileIn, unsigned int nPosIn) :
30
+ nFile ( nFileIn),
31
+ nPos ( nPosIn)
32
+ { }
35
33
36
34
friend bool operator ==(const FlatFilePos &a, const FlatFilePos &b) {
37
35
return (a.nFile == b.nFile && a.nPos == b.nPos );
@@ -72,7 +70,7 @@ class FlatFileSeq
72
70
fs::path FileName (const FlatFilePos& pos) const ;
73
71
74
72
/* * Open a handle to the file at the given position. */
75
- FILE* Open (const FlatFilePos& pos, bool fReadOnly = false );
73
+ FILE* Open (const FlatFilePos& pos, bool read_only = false );
76
74
77
75
/* *
78
76
* Allocate additional space in a file after the given starting position. The amount allocated
Original file line number Diff line number Diff line change @@ -135,12 +135,12 @@ bool DirIsWritable(const fs::path& directory)
135
135
return true ;
136
136
}
137
137
138
- bool CheckDiskSpace (const fs::path& dir, uint64_t nAdditionalBytes )
138
+ bool CheckDiskSpace (const fs::path& dir, uint64_t additional_bytes )
139
139
{
140
- constexpr uint64_t nMinDiskSpace = 52428800 ; // 50 MiB
140
+ constexpr uint64_t min_disk_space = 52428800 ; // 50 MiB
141
141
142
- uint64_t nFreeBytesAvailable = fs::space (dir).available ;
143
- return nFreeBytesAvailable >= nMinDiskSpace + nAdditionalBytes ;
142
+ uint64_t free_bytes_available = fs::space (dir).available ;
143
+ return free_bytes_available >= min_disk_space + additional_bytes ;
144
144
}
145
145
146
146
/* *
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ bool RenameOver(fs::path src, fs::path dest);
72
72
bool LockDirectory (const fs::path& directory, const std::string lockfile_name, bool probe_only=false );
73
73
void UnlockDirectory (const fs::path& directory, const std::string& lockfile_name);
74
74
bool DirIsWritable (const fs::path& directory);
75
- bool CheckDiskSpace (const fs::path& dir, uint64_t nAdditionalBytes = 0 );
75
+ bool CheckDiskSpace (const fs::path& dir, uint64_t additional_bytes = 0 );
76
76
77
77
/* * Release all directory locks. This is used for unit testing only, at runtime
78
78
* the global destructor will take care of the locks.
You can’t perform that action at this time.
0 commit comments