mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 16:57:46 +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 std::string getExtension(const std::string &filePath);
|
||||||
|
|
||||||
|
static void copy(const std::string & from, const std::string & to);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Create a UFile object with path initialized to an existing file .
|
* Create a UFile object with path initialized to an existing file .
|
||||||
@@ -128,6 +130,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::string getExtension() {return getExtension(path_);}
|
std::string getExtension() {return getExtension(path_);}
|
||||||
|
|
||||||
|
void copy(const std::string & to) {copy(path_, to);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string path_;
|
std::string path_;
|
||||||
};
|
};
|
||||||
|
|||||||
+10
-2
@@ -57,13 +57,13 @@ long UFile::length(const std::string &filePath)
|
|||||||
|
|
||||||
int UFile::erase(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,
|
int UFile::rename(const std::string &oldFilePath,
|
||||||
const std::string &newFilePath)
|
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)
|
std::string UFile::getName(const std::string & filePath)
|
||||||
@@ -93,3 +93,11 @@ std::string UFile::getExtension(const std::string &filePath)
|
|||||||
}
|
}
|
||||||
return "";
|
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