utilite
include
rtabmap
utilite
UFile.h
Go to the documentation of this file.
1
/*
2
* utilite is a cross-platform library with
3
* useful utilities for fast and small developing.
4
* Copyright (C) 2010 Mathieu Labbe
5
*
6
* utilite is free library: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* utilite is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef FILE_H
21
#define FILE_H
22
23
#include "rtabmap/utilite/utilite_export.h"
// DLL export/import defines
24
25
#include "
rtabmap/utilite/UDirectory.h
"
26
#include <string>
27
33
class
UTILITE_EXPORT
UFile
34
{
35
public
:
41
static
bool
exists(
const
std::string &filePath);
42
48
static
long
length
(
const
std::string &filePath);
49
55
static
int
erase(
const
std::string &filePath);
56
63
static
int
rename(
const
std::string &oldFilePath,
64
const
std::string &newFilePath);
65
71
static
std::string
getName
(
const
std::string & filePath);
72
77
static
std::string getExtension(
const
std::string &filePath);
78
84
static
void
copy
(
const
std::string & from,
const
std::string & to);
85
86
public
:
91
UFile
(
const
std::string & path) : path_(
path
) {}
92
~UFile
() {}
93
98
bool
isValid
() {
return
exists(path_);}
99
104
bool
exists
() {
return
exists
(path_);}
105
110
long
length
() {
return
length
(path_);}
111
116
int
rename
(
const
std::string &newName)
117
{
118
std::string ext = this->getExtension();
119
std::string newPath =
UDirectory::getDir
(path_) + std::string(
"/"
) + newName;
120
if
(ext.size())
121
{
122
newPath += std::string(
"."
) + getExtension(path_);
123
}
124
int
result
= rename(path_, newPath);
125
if
(
result
== 0)
126
{
127
path_ = newPath;
128
}
129
return
result
;
130
}
135
std::string
getName
() {
return
getName
(path_);}
140
std::string
getExtension
() {
return
getExtension
(path_);}
141
146
void
copy
(
const
std::string & to) {
copy
(path_, to);}
147
148
private
:
149
std::string
path_
;
150
};
151
152
#endif
UFile::getName
std::string getName()
Definition:
UFile.h:135
glm::length
GLM_FUNC_DECL genType::value_type length(genType const &x)
UFile
Definition:
UFile.h:33
UFile::copy
void copy(const std::string &to)
Definition:
UFile.h:146
UFile::length
long length()
Definition:
UFile.h:110
UDirectory.h
getName
ROSCONSOLE_CONSOLE_IMPL_DECL std::string getName(void *handle)
copy
int EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
UFile::rename
int rename(const std::string &newName)
Definition:
UFile.h:116
UFile::UFile
UFile(const std::string &path)
Definition:
UFile.h:91
UDirectory::getDir
static std::string getDir(const std::string &filePath)
Definition:
UDirectory.cpp:273
UFile::~UFile
~UFile()
Definition:
UFile.h:92
UFile::getExtension
std::string getExtension()
Definition:
UFile.h:140
UFile::isValid
bool isValid()
Definition:
UFile.h:98
path
path
UFile::path_
std::string path_
Definition:
UFile.h:149
UFile::exists
bool exists()
Definition:
UFile.h:104
result
RESULT & result
rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:23