refactored files. moved around. added OS encapsulation layer.

pull/40/head
Matchman Green 2012-04-27 10:49:33 +08:00
parent 7b50d2633d
commit dfd7eac5d9
10 changed files with 75 additions and 12 deletions

View File

@ -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

View File

@ -20,13 +20,10 @@
#include "Collection.hh"
#include "protocol/Json.hh"
#include "util/OS.hh"
#include <cassert>
// OS specific library
#include <sys/stat.h>
#include <sys/types.h>
// for debugging
#include <iostream>
@ -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<Collection*>::iterator i = m_child.begin() ; i != m_child.end() ; ++i )
{

View File

@ -21,7 +21,7 @@
#include "protocol/HTTP.hh"
#include "protocol/Json.hh"
#include "OAuth2.hh"
#include "protocol/OAuth2.hh"
// dependent libraries
#include <openssl/evp.h>

View File

@ -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 <cassert>

33
src/util/OS.cc Normal file
View File

@ -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 <sys/stat.h>
#include <sys/types.h>
namespace gr { namespace os {
void MakeDir( const std::string& dir )
{
mkdir( dir.c_str(), 0700 ) ;
}
} } // end of namespaces

28
src/util/OS.hh Normal file
View File

@ -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 <string>
namespace gr { namespace os {
void MakeDir( const std::string& dir ) ;
} } // end of namespaces