diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-10-17 18:47:09 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-10-17 18:47:09 +0100 |
| commit | 44281c8fedfd923b951580cf42bc768991eae502 (patch) | |
| tree | 12af1afe01f44c8487519756a5b4804d7cb4b3b2 /src/file.cc | |
| parent | c3bafea2cd17c1df58ef4714c9037b814c6b7937 (diff) | |
More robust Buffer filesystem timestamp handling
Diffstat (limited to 'src/file.cc')
| -rw-r--r-- | src/file.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/file.cc b/src/file.cc index 18682ac3..c10f936d 100644 --- a/src/file.cc +++ b/src/file.cc @@ -175,8 +175,8 @@ Buffer* create_buffer_from_file(String filename) else pos = line_end + 1; } - Buffer* buffer = new Buffer(filename, Buffer::Flags::File, std::move(lines)); - buffer->set_fs_timestamp(st.st_mtime); + Buffer* buffer = new Buffer{filename, Buffer::Flags::File, + std::move(lines), st.st_mtime}; OptionManager& options = buffer->options(); options.get_local_option("eolformat").set<String>(crlf ? "crlf" : "lf"); @@ -228,7 +228,7 @@ void write_buffer_to_file(Buffer& buffer, const String& filename) write(fd, eoldata, filename); } if ((buffer.flags() & Buffer::Flags::File) and filename == buffer.name()) - buffer.set_fs_timestamp(get_fs_timestamp(filename)); + buffer.notify_saved(); } String find_file(const String& filename, memoryview<String> paths) @@ -312,7 +312,7 @@ time_t get_fs_timestamp(const String& filename) { struct stat st; if (stat(filename.c_str(), &st) != 0) - throw runtime_error("stat failed on " + filename); + return InvalidTime; return st.st_mtime; } |
