diff --git a/libgrive/src/drive/Entry.cc b/libgrive/src/drive/Entry.cc index 4fa8bbc..ba77408 100644 --- a/libgrive/src/drive/Entry.cc +++ b/libgrive/src/drive/Entry.cc @@ -61,7 +61,7 @@ void Entry::FromLocal( const fs::path& path ) m_filename = path.filename().string() ; m_kind = fs::is_directory(path) ? "folder" : "file" ; m_md5 = fs::is_directory(path) ? "" : crypt::MD5( path ) ; - m_mtime = fs::exists(path) ? os::FileMTime( path ) : DateTime() ; + m_mtime = fs::exists(path) ? os::FileCTime( path ) : DateTime() ; } void Entry::Update( const xml::Node& n ) diff --git a/libgrive/src/drive/Resource.cc b/libgrive/src/drive/Resource.cc index f56c12c..0b7690f 100644 --- a/libgrive/src/drive/Resource.cc +++ b/libgrive/src/drive/Resource.cc @@ -179,7 +179,7 @@ void Resource::FromLocal( const DateTime& last_sync ) // if the file is not created after last sync, assume file is // remote_deleted first, it will be updated to sync/remote_changed // in FromRemote() - DateTime mtime = os::FileMTime( path ) ; + DateTime mtime = os::FileCTime( path ) ; m_state = ( mtime > last_sync ? local_new : remote_deleted ) ; m_entry.FromLocal( path ) ; diff --git a/libgrive/src/util/OS.cc b/libgrive/src/util/OS.cc index 31cc959..0d51136 100644 --- a/libgrive/src/util/OS.cc +++ b/libgrive/src/util/OS.cc @@ -39,12 +39,12 @@ namespace gr { namespace os { -DateTime FileMTime( const fs::path& filename ) +DateTime FileCTime( const fs::path& filename ) { - return FileMTime( filename.string() ) ; + return FileCTime( filename.string() ) ; } -DateTime FileMTime( const std::string& filename ) +DateTime FileCTime( const std::string& filename ) { struct stat s = {} ; if ( ::stat( filename.c_str(), &s ) != 0 ) @@ -58,9 +58,9 @@ DateTime FileMTime( const std::string& filename ) } #if defined __APPLE__ && defined __DARWIN_64_BIT_INO_T - return DateTime( s.st_mtimespec.tv_sec, s.st_mtimespec.tv_nsec ) ; + return DateTime( s.st_ctimespec.tv_sec, s.st_ctimespec.tv_nsec ) ; #else - return DateTime( s.st_mtim.tv_sec, s.st_mtim.tv_nsec); + return DateTime( s.st_ctim.tv_sec, s.st_ctim.tv_nsec); #endif } diff --git a/libgrive/src/util/OS.hh b/libgrive/src/util/OS.hh index efcb055..4a0350d 100644 --- a/libgrive/src/util/OS.hh +++ b/libgrive/src/util/OS.hh @@ -33,8 +33,8 @@ namespace os { struct Error : virtual Exception {} ; - DateTime FileMTime( const std::string& filename ) ; - DateTime FileMTime( const fs::path& filename ) ; + DateTime FileCTime( const std::string& filename ) ; + DateTime FileCTime( const fs::path& filename ) ; void SetFileTime( const std::string& filename, const DateTime& t ) ; void SetFileTime( const fs::path& filename, const DateTime& t ) ;