update cppcommon

This commit is contained in:
gwdwyy 2013-07-27 14:54:42 +08:00
parent 0fd8c4bd56
commit ff5677ef78
5 changed files with 26 additions and 13 deletions

View File

@ -5,8 +5,8 @@ AR := ar rc
INCS := -I. -I./cppcommon
DEBUG_CXXFLAGS := -g -DDEBUG
RELEASE_CXXFLAGS := -Wall
DEBUG_CXXFLAGS := -g -Wall -DDEBUG
RELEASE_CXXFLAGS := -Wall -O3
ifeq (YES, ${DEBUG})
CXXFLAGS := ${DEBUG_CXXFLAGS}

View File

@ -23,7 +23,7 @@ $(CMLIB): $(OBJS)
$(DOPACK)
file_functs.test: file_functs.cpp file_functs.h
file_functs.ut: file_functs.cpp file_functs.h
g++ -o $@ $< -DTEST_FILE_FUNCTS
io_functs.test: io_functs.cpp io_functs.h
g++ -o $@ $< -DTEST_IO_FUNCTS

View File

@ -6,18 +6,17 @@
namespace CPPCOMMON
{
using namespace std;
bool checkFileExist(const char * filepath)
bool checkFileExist(const string& filePath)
{
fstream _file;
_file.open(filepath, ios::in);
_file.open(filePath.c_str(), ios::in);
if(_file)
return true;
return false;
}
bool createDir(const char * dir_path, bool p)
bool createDir(const string& dirPath, bool p)
{
string dir_str(dir_path);
string dir_str(dirPath);
string cmd = "mkdir";
if(p)
{
@ -27,9 +26,9 @@ namespace CPPCOMMON
int res = system(cmd.c_str());
return res;
}
bool checkDirExist(const char * dir_path)
bool checkDirExist(const string& dirPath)
{
return checkFileExist(dir_path);
return checkFileExist(dirPath);
}
}

View File

@ -11,9 +11,10 @@
#include <stdlib.h>
namespace CPPCOMMON
{
bool checkFileExist(const char * filepath);
bool createDir(const char * dir_path, bool p = true);
bool checkDirExist(const char * dir_path);
using namespace std;
bool checkFileExist(const string& filePath);
bool createDir(const string& dirPath, bool p = true);
bool checkDirExist(const string& dirPath);
}

13
src/cppcommon/headers.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef CPPCOMMON_HEADERS_H
#define CPPCOMMON_HEADERS_H
#include "logger.h"
#include "file_functs.h"
#include "vec_functs.h"
#include "io_functs.h"
#include "encoding.h"
#include "config.h"
#include "typedefs.h"
#include "str_functs.h"
#endif