mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Added UFile::copy()
git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@909 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
@@ -72,6 +72,8 @@ public:
|
||||
|
||||
static std::string getExtension(const std::string &filePath);
|
||||
|
||||
static void copy(const std::string & from, const std::string & to);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a UFile object with path initialized to an existing file .
|
||||
@@ -128,6 +130,8 @@ public:
|
||||
*/
|
||||
std::string getExtension() {return getExtension(path_);}
|
||||
|
||||
void copy(const std::string & to) {copy(path_, to);}
|
||||
|
||||
private:
|
||||
std::string path_;
|
||||
};
|
||||
|
||||
@@ -57,13 +57,13 @@ long UFile::length(const std::string &filePath)
|
||||
|
||||
int UFile::erase(const std::string &filePath)
|
||||
{
|
||||
return remove(filePath.c_str());
|
||||
return std::remove(filePath.c_str());
|
||||
}
|
||||
|
||||
int UFile::rename(const std::string &oldFilePath,
|
||||
const std::string &newFilePath)
|
||||
{
|
||||
return rename(oldFilePath.c_str(), newFilePath.c_str());
|
||||
return std::rename(oldFilePath.c_str(), newFilePath.c_str());
|
||||
}
|
||||
|
||||
std::string UFile::getName(const std::string & filePath)
|
||||
@@ -93,3 +93,11 @@ std::string UFile::getExtension(const std::string &filePath)
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void UFile::copy(const std::string & from, const std::string & to)
|
||||
{
|
||||
std::ifstream src(from.c_str());
|
||||
std::ofstream dst(to.c_str());
|
||||
|
||||
dst << src.rdbuf();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user