From 8553e63936fade1c4cef99a26ed3bf81d56796cd Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Fri, 4 Nov 2016 16:21:50 -0400 Subject: [PATCH] linux. --- native/Linux.cpp | 11 ++++++----- native/file.cpp | 4 ++-- native/file.h | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/native/Linux.cpp b/native/Linux.cpp index 7ad8d1b..eb99262 100644 --- a/native/Linux.cpp +++ b/native/Linux.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -52,12 +53,13 @@ namespace { class xattr_file final : public native::file { public: - xattr_file(const std::string &path, int fd, bool readonly): file(path), _fd(fd), _readonly(readonly); + xattr_file(const std::string &path, int fd, bool readonly): file(path), _fd(fd), _readonly(readonly) + {} ~xattr_file(); virtual tool_return read(void *out_buffer, size_t count) override; - virtual tool_return write(void *in_buffer, size_t count) override; + virtual tool_return write(const void *in_buffer, size_t count) override; virtual tool_return get_mark() override; virtual tool_return set_mark(ssize_t new_mark) override; virtual tool_return get_eof() override; @@ -104,7 +106,6 @@ namespace { return count; } - tool_return xattr_file::write(const void *in_buffer, size_t count) { if (_readonly) return MacOS::wrPermErr; @@ -199,10 +200,10 @@ namespace native { { struct stat st; - if (stat(path_name.c_str(), &st) < 0) + if (::stat(path_name.c_str(), &st) < 0) return macos_error_from_errno(); - fi.create_date = unix_to_mac(st.st_birthtime); + fi.create_date = unix_to_mac(st.st_ctime); fi.modify_date = unix_to_mac(st.st_mtime); fi.backup_date = 0; diff --git a/native/file.cpp b/native/file.cpp index 704bfa6..a9adc50 100644 --- a/native/file.cpp +++ b/native/file.cpp @@ -100,7 +100,7 @@ tool_return fd_file::read(void *buffer, size_t count) { return ok; } -tool_return fd_file::write(void *buffer, size_t count) { +tool_return fd_file::write(const void *buffer, size_t count) { if (_interactive || text) { @@ -186,7 +186,7 @@ tool_return empty_file::read(void *out_buffer, size_t count) { if (count == 0) return 0; return 0; // eofErr handled elsewhere. } -tool_return empty_file::write(void *in_buffer, size_t count) { +tool_return empty_file::write(const void *in_buffer, size_t count) { return MacOS::wrPermErr; } tool_return empty_file::seek(ssize_t position, int whence) { diff --git a/native/file.h b/native/file.h index 90ae0d2..64a1f66 100644 --- a/native/file.h +++ b/native/file.h @@ -24,7 +24,7 @@ public: virtual ~file() = default; virtual tool_return read(void *out_buffer, size_t count) = 0; - virtual tool_return write(void *in_buffer, size_t count) = 0; + virtual tool_return write(const void *in_buffer, size_t count) = 0; virtual tool_return seek(ssize_t position, int whence); virtual tool_return get_mark() = 0; virtual tool_return set_mark(ssize_t new_mark) = 0; @@ -49,7 +49,7 @@ public: virtual ~fd_file(); virtual tool_return read(void *out_buffer, size_t count) override; - virtual tool_return write(void *in_buffer, size_t count) override; + virtual tool_return write(const void *in_buffer, size_t count) override; virtual tool_return seek(ssize_t position, int whence) override; virtual tool_return get_mark() override; virtual tool_return set_mark(ssize_t new_mark) override; @@ -69,7 +69,7 @@ public: empty_file(const std::string &s) : file(s) {} virtual tool_return read(void *out_buffer, size_t count) override; - virtual tool_return write(void *in_buffer, size_t count) override; + virtual tool_return write(const void *in_buffer, size_t count) override; virtual tool_return seek(ssize_t position, int whence) override; virtual tool_return get_mark() override; virtual tool_return set_mark(ssize_t new_mark) override;