From 56e605c392a68dea309126f69ec6e1f9393cd85f Mon Sep 17 00:00:00 2001 From: Matchman Green Date: Wed, 9 May 2012 23:09:19 +0800 Subject: [PATCH] renamed File to Entry, because it is common between file & folder --- libgrive/src/drive/Drive.cc | 5 ++-- libgrive/src/drive/{File.cc => Entry.cc} | 34 ++++++++++++------------ libgrive/src/drive/{File.hh => Entry.hh} | 6 ++--- 3 files changed, 22 insertions(+), 23 deletions(-) rename libgrive/src/drive/{File.cc => Entry.cc} (85%) rename libgrive/src/drive/{File.hh => Entry.hh} (95%) diff --git a/libgrive/src/drive/Drive.cc b/libgrive/src/drive/Drive.cc index cd8c8fd..b65e82c 100644 --- a/libgrive/src/drive/Drive.cc +++ b/libgrive/src/drive/Drive.cc @@ -20,7 +20,7 @@ #include "Drive.hh" #include "CommonUri.hh" -#include "File.hh" +#include "Entry.hh" #include "http/HTTP.hh" #include "http/XmlResponse.hh" @@ -187,7 +187,7 @@ void Drive::UpdateFile( const Json& entry ) // only handle uploaded files if ( entry.Has( "docs$suggestedFilename" ) ) { - File file( entry ) ; + Entry file( entry ) ; bool changed = true ; Path path = Path() / file.Filename() ; @@ -199,7 +199,6 @@ void Drive::UpdateFile( const Json& entry ) if ( pit != m_coll.end() ) path = pit->Dir() / file.Filename() ; } -// std::cout << "2:" << path << std::endl; // compare checksum first if file exists std::ifstream ifile( path.Str().c_str(), std::ios::binary | std::ios::in ) ; diff --git a/libgrive/src/drive/File.cc b/libgrive/src/drive/Entry.cc similarity index 85% rename from libgrive/src/drive/File.cc rename to libgrive/src/drive/Entry.cc index 5154e46..406e1fc 100644 --- a/libgrive/src/drive/File.cc +++ b/libgrive/src/drive/Entry.cc @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "File.hh" +#include "Entry.hh" #include "CommonUri.hh" @@ -37,16 +37,16 @@ namespace gr { -File::File( const Path& file ) +Entry::Entry( const Path& file ) { } -File::File( const Json& entry ) +Entry::Entry( const Json& entry ) { Update( entry ) ; } -void File::Update( const Json& entry ) +void Entry::Update( const Json& entry ) { m_title = entry["title"]["$t"].Str() ; @@ -80,49 +80,49 @@ void File::Update( const Json& entry ) tolower ) ; } -std::string File::Parent( const Json& entry ) +std::string Entry::Parent( const Json& entry ) { Json node ; return entry["link"].FindInArray( "rel", "http://schemas.google.com/docs/2007#parent", node ) ? node["href"].Str() : std::string() ; } -std::string File::Title() const +std::string Entry::Title() const { return m_title ; } -std::string File::Filename() const +std::string Entry::Filename() const { return m_filename ; } -std::string File::Kind() const +std::string Entry::Kind() const { return m_kind ; } -std::string File::ServerMD5() const +std::string Entry::ServerMD5() const { return m_server_md5 ; } -DateTime File::ServerModified() const +DateTime Entry::ServerModified() const { return m_server_modified ; } -std::string File::Href() const +std::string Entry::Href() const { return m_href ; } -std::string File::Parent() const +std::string Entry::Parent() const { return m_parent ; } -void File::Download( const Path& file, const http::Headers& auth ) const +void Entry::Download( const Path& file, const http::Headers& auth ) const { gr::Download dl( file.Str(), Download::NoChecksum() ) ; http::Agent http ; @@ -131,7 +131,7 @@ void File::Download( const Path& file, const http::Headers& auth ) const os::SetFileTime( file, m_server_modified ) ; } -bool File::Upload( std::streambuf *file, const http::Headers& auth ) +bool Entry::Upload( std::streambuf *file, const http::Headers& auth ) { // upload link missing means that file is read only if ( m_upload_link.empty() ) @@ -178,17 +178,17 @@ std::cout << xml.Response() << std::endl ; return true ; } -std::string File::ResourceID() const +std::string Entry::ResourceID() const { return m_resource_id ; } -std::string File::ETag() const +std::string Entry::ETag() const { return m_etag ; } -void File::Delete( http::Agent *http, const http::Headers& auth ) +void Entry::Delete( http::Agent *http, const http::Headers& auth ) { http::Headers hdr( auth ) ; hdr.push_back( "If-Match: " + m_etag ) ; diff --git a/libgrive/src/drive/File.hh b/libgrive/src/drive/Entry.hh similarity index 95% rename from libgrive/src/drive/File.hh rename to libgrive/src/drive/Entry.hh index f4b673f..68f28b1 100644 --- a/libgrive/src/drive/File.hh +++ b/libgrive/src/drive/Entry.hh @@ -32,11 +32,11 @@ class Json ; class OAuth2 ; class Path ; -class File +class Entry { public : - explicit File( const Path& file ) ; - explicit File( const Json& entry ) ; + explicit Entry( const Path& file ) ; + explicit Entry( const Json& entry ) ; std::string Title() const ; std::string Filename() const ;