MCPcopy Create free account
hub / github.com/ElementsProject/elements / Read

Method Read

src/leveldb/util/env_posix.cc:173–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171 }
172
173 Status Read(uint64_t offset, size_t n, Slice* result,
174 char* scratch) const override {
175 int fd = fd_;
176 if (!has_permanent_fd_) {
177 fd = ::open(filename_.c_str(), O_RDONLY | kOpenBaseFlags);
178 if (fd < 0) {
179 return PosixError(filename_, errno);
180 }
181 }
182
183 assert(fd != -1);
184
185 Status status;
186 ssize_t read_size = ::pread(fd, scratch, n, static_cast<off_t>(offset));
187 *result = Slice(scratch, (read_size < 0) ? 0 : read_size);
188 if (read_size < 0) {
189 // An error: return a non-ok status.
190 status = PosixError(filename_, errno);
191 }
192 if (!has_permanent_fd_) {
193 // Close the temporary file descriptor opened earlier.
194 assert(fd != fd_);
195 ::close(fd);
196 }
197 return status;
198 }
199
200 virtual std::string GetName() const override { return filename_; }
201

Callers

nothing calls this directly

Calls 2

PosixErrorFunction · 0.85
SliceClass · 0.70

Tested by

no test coverage detected