mirror of https://github.com/vitalif/grive2
renamed File to Entry, because it is common between file & folder
parent
7a66605a5f
commit
56e605c392
|
@ -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 ) ;
|
||||
|
|
|
@ -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 ) ;
|
|
@ -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 ;
|
Loading…
Reference in New Issue