diff --git a/CMakeLists.txt b/CMakeLists.txt index 167a7ac..3d94a95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,14 +4,18 @@ cmake_minimum_required(VERSION 2.8) include(FindOpenSSL) +include_directories( ${grive_SOURCE_DIR}/src ) + add_executable( grive src/main.cc - src/OAuth2.cc - src/Drive.cc - src/Collection.cc + src/drive/Collection.cc + src/drive/Drive.cc + src/protocol/Download.cc src/protocol/HTTP.cc src/protocol/Json.cc - src/protocol/Download.cc ) + src/protocol/OAuth2.cc + src/util/OS.cc +) target_link_libraries( grive curl diff --git a/src/Collection.cc b/src/drive/Collection.cc similarity index 96% rename from src/Collection.cc rename to src/drive/Collection.cc index f660dfc..8fc5ce5 100644 --- a/src/Collection.cc +++ b/src/drive/Collection.cc @@ -20,13 +20,10 @@ #include "Collection.hh" #include "protocol/Json.hh" +#include "util/OS.hh" #include -// OS specific library -#include -#include - // for debugging #include @@ -104,7 +101,8 @@ void Collection::Swap( Collection& coll ) void Collection::CreateSubDir( const std::string& prefix ) { std::string dir = prefix + m_title ; - mkdir( dir.c_str(), 0700 ) ; +// mkdir( dir.c_str(), 0700 ) ; + os::MakeDir( dir ) ; for ( std::vector::iterator i = m_child.begin() ; i != m_child.end() ; ++i ) { diff --git a/src/Collection.hh b/src/drive/Collection.hh similarity index 100% rename from src/Collection.hh rename to src/drive/Collection.hh diff --git a/src/Drive.cc b/src/drive/Drive.cc similarity index 99% rename from src/Drive.cc rename to src/drive/Drive.cc index 60c0ca5..06267ca 100644 --- a/src/Drive.cc +++ b/src/drive/Drive.cc @@ -21,7 +21,7 @@ #include "protocol/HTTP.hh" #include "protocol/Json.hh" -#include "OAuth2.hh" +#include "protocol/OAuth2.hh" // dependent libraries #include diff --git a/src/Drive.hh b/src/drive/Drive.hh similarity index 100% rename from src/Drive.hh rename to src/drive/Drive.hh diff --git a/src/main.cc b/src/main.cc index 4df7d9e..1d1c123 100644 --- a/src/main.cc +++ b/src/main.cc @@ -17,8 +17,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "OAuth2.hh" -#include "Drive.hh" +#include "drive/Drive.hh" +#include "protocol/OAuth2.hh" #include "protocol/Json.hh" #include diff --git a/src/OAuth2.cc b/src/protocol/OAuth2.cc similarity index 100% rename from src/OAuth2.cc rename to src/protocol/OAuth2.cc diff --git a/src/OAuth2.hh b/src/protocol/OAuth2.hh similarity index 100% rename from src/OAuth2.hh rename to src/protocol/OAuth2.hh diff --git a/src/util/OS.cc b/src/util/OS.cc new file mode 100644 index 0000000..a69dd2f --- /dev/null +++ b/src/util/OS.cc @@ -0,0 +1,33 @@ +/* + grive: an GPL program to sync a local directory with Google Drive + Copyright (C) 2012 Wan Wai Ho + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation version 2 + of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "OS.hh" + +// OS specific headers +#include +#include + +namespace gr { namespace os { + +void MakeDir( const std::string& dir ) +{ + mkdir( dir.c_str(), 0700 ) ; +} + +} } // end of namespaces diff --git a/src/util/OS.hh b/src/util/OS.hh new file mode 100644 index 0000000..59d542e --- /dev/null +++ b/src/util/OS.hh @@ -0,0 +1,28 @@ +/* + grive: an GPL program to sync a local directory with Google Drive + Copyright (C) 2012 Wan Wai Ho + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation version 2 + of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#pragma once + +#include + +namespace gr { namespace os { + +void MakeDir( const std::string& dir ) ; + +} } // end of namespaces