summaryrefslogtreecommitdiff
path: root/src/file.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-10-16 13:58:56 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-10-17 11:33:09 +0100
commit76fadd81081d7bb762d143dfd2ecca73637328a7 (patch)
tree8619b5d6b599abd7ef7471f5ee224d89eabbd6a1 /src/file.hh
parentfe704b9b8433145602b1ec63f030ea98b378811d (diff)
More cleanups in the buffer open/reload code
Diffstat (limited to 'src/file.hh')
-rw-r--r--src/file.hh13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/file.hh b/src/file.hh
index b3ba0578..98431adc 100644
--- a/src/file.hh
+++ b/src/file.hh
@@ -45,14 +45,14 @@ String read_file(StringView filename, bool text = false);
struct MappedFile
{
- int fd;
- const char* data = nullptr;
- struct stat st {};
-
- explicit operator bool() const { return fd != -1; }
-
MappedFile(StringView filename);
~MappedFile();
+
+ operator StringView() const { return { data, (int)st.st_size }; }
+
+ int fd;
+ const char* data;
+ struct stat st {};
};
void write_buffer_to_file(Buffer& buffer, StringView filename);
@@ -60,6 +60,7 @@ void write_buffer_to_fd(Buffer& buffer, int fd);
void write_buffer_to_backup_file(Buffer& buffer);
String find_file(StringView filename, ConstArrayView<String> paths);
+bool file_exists(StringView filename);
Vector<String> list_files(StringView directory);