Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile on OS X #2

Merged
merged 4 commits into from Apr 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
@@ -1,2 +1,6 @@
.kdev4
grive.kdev4

.project
.cproject
build/
16 changes: 14 additions & 2 deletions src/main.cc
Expand Up @@ -27,6 +27,9 @@
#include <iostream>
#include <iterator>

#include <exception>
#include <stdexcept>

const std::string client_id = "22314510474.apps.googleusercontent.com" ;
const std::string client_secret = "bl4ufi89h-9MkFlypcI7R785" ;

Expand Down Expand Up @@ -102,8 +105,17 @@ int main( int argc, char **argv )
}
}

OAuth2 token( config["refresh_token"].As<std::string>(), client_id, client_secret ) ;
Drive drive( token ) ;
try
{
OAuth2 token( config["refresh_token"].As<std::string>(), client_id, client_secret ) ;
Drive drive( token ) ;
}
catch ( const std::runtime_error& error )
{
std::cerr << "Please run grive with the \"-a\" option if this is the "
<< "first time you're accessing your Google Drive!\n";
return -1;
}

return 0 ;
}
6 changes: 5 additions & 1 deletion src/util/OS.cc
Expand Up @@ -40,7 +40,11 @@ DateTime FileMTime( const std::string& filename )
if ( ::stat( filename.c_str(), &s ) != 0 )
throw std::runtime_error( "cannot get file attribute of " + filename ) ;

return DateTime( s.st_mtim.tv_sec, s.st_mtim.tv_nsec ) ;
#ifdef __APPLE__ && __DARWIN_64_BIT_INO_T
return DateTime( s.st_mtimespec.tv_sec, s.st_mtimespec.tv_nsec ) ;
#else
return DateTime( s.st_mtim.tv_sec, s.st_mtim.tv_nsec);
#endif
}

void SetFileTime( const std::string& filename, const DateTime& t )
Expand Down