Commit f2a5cc1 1 parent 2b016a9 commit f2a5cc1 Copy full SHA for f2a5cc1
File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 10
10
#include < cstddef>
11
11
#include < cstdint>
12
12
#include < cstdio>
13
+ #include < cstring>
13
14
#include < fcntl.h>
14
15
#include < ios>
15
16
#include < stdexcept>
@@ -67,6 +68,20 @@ void LocalFile::notifyUnused() {
67
68
// NOOP.
68
69
}
69
70
71
+ absl::Status LocalFile::fsync () {
72
+ CHECK_FILE_OPEN
73
+
74
+ int e = 0 ;
75
+ do {
76
+ e = ::fsync (_fd);
77
+ } while (e != 0 && errno == EINTR);
78
+ if (e != 0 ) {
79
+ int err = errno;
80
+ return absl::UnknownError (" Unable to fsync " + _path + " : " + strerror (err));
81
+ }
82
+ return absl::OkStatus ();
83
+ }
84
+
70
85
absl::StatusOr<size_t > LocalFile::fileSize () const {
71
86
CHECK_FILE_OPEN
72
87
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ class LocalFile {
49
49
50
50
void notifyUnused ();
51
51
52
+ absl::Status fsync ();
53
+
52
54
[[nodiscard]] size_t size () const { return _size; }
53
55
[[nodiscard]] size_t localStorageSize () const { return _size; }
54
56
[[nodiscard]] size_t localMemorySize () const { return 0 ; }
You can’t perform that action at this time.
0 commit comments