aboutsummaryrefslogtreecommitdiff
path: root/src/posix_extras.h
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2016-02-21 19:23:11 -0500
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2016-02-21 20:38:03 -0500
commit6aa9095865017c06a61f0cb10c1f1231a89b761c (patch)
tree0303312d8f9b2e1671a8e74d6ff11147c153bea0 /src/posix_extras.h
parent384f7c422acca2f3658393abfc16ea57cd74caa6 (diff)
Implement fgetattr and read
Diffstat (limited to 'src/posix_extras.h')
-rw-r--r--src/posix_extras.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/posix_extras.h b/src/posix_extras.h
index a73f9fe..5571da6 100644
--- a/src/posix_extras.h
+++ b/src/posix_extras.h
@@ -15,8 +15,10 @@
#ifndef POSIX_EXTRAS_H_
#define POSIX_EXTRAS_H_
+#include <cstdint>
#include <experimental/optional>
#include <string>
+#include <vector>
#include <dirent.h>
#include <sys/stat.h>
@@ -78,6 +80,11 @@ class File {
}
File OpenAt(const char* path, int flags, mode_t mode) const;
+ // Reads exactly the specified number of bytes from the file at the given
+ // offset, unless doing so would run past the end of the file, in which case
+ // fewer bytes are returned.
+ std::vector<std::uint8_t> Read(off_t, size_t) const;
+
// Removes the file at the path relative to the file descriptor. The path
// must indeed be relative (i.e., it must not start with '/').
void UnlinkAt(const char* path) const;