Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef FILE_H
00021 #define FILE_H
00022
00023 #include "rtabmap/utilite/UtiLiteExp.h"
00024
00025 #include "rtabmap/utilite/UDirectory.h"
00026 #include <string>
00027
00033 class UTILITE_EXP UFile
00034 {
00035 public:
00041 static bool exists(const std::string &filePath);
00042
00048 static long length(const std::string &filePath);
00049
00055 static int erase(const std::string &filePath);
00056
00063 static int rename(const std::string &oldFilePath,
00064 const std::string &newFilePath);
00065
00071 static std::string getName(const std::string & filePath);
00072
00077 static std::string getExtension(const std::string &filePath);
00078
00084 static void copy(const std::string & from, const std::string & to);
00085
00086 public:
00091 UFile(const std::string & path) : path_(path) {}
00092 ~UFile() {}
00093
00098 bool isValid() {return exists(path_);}
00099
00104 bool exists() {return exists(path_);}
00105
00110 long length() {return length(path_);}
00111
00116 int rename(const std::string &newName)
00117 {
00118 std::string ext = this->getExtension();
00119 std::string newPath = UDirectory::getDir(path_) + std::string("/") + newName;
00120 if(ext.size())
00121 {
00122 newPath += std::string(".") + getExtension(path_);
00123 }
00124 int result = rename(path_, newPath);
00125 if(result == 0)
00126 {
00127 path_ = newPath;
00128 }
00129 return result;
00130 }
00135 std::string getName() {return getName(path_);}
00140 std::string getExtension() {return getExtension(path_);}
00141
00146 void copy(const std::string & to) {copy(path_, to);}
00147
00148 private:
00149 std::string path_;
00150 };
00151
00152 #endif