Removed trailing separator from working directory. Replaced all slashes by QDir::separator().

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1935 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2014-10-28 05:00:10 +00:00
parent 850c277dac
commit 9ffd103e69
5 changed files with 27 additions and 35 deletions
-2
View File
@@ -60,8 +60,6 @@ std::string Parameters::getDefaultWorkingDirectory()
{
UFATAL("Can't get the HOME variable environment!");
}
path += UDirectory::separator(); // add trailing separator
return path;
}
+10 -15
View File
@@ -115,7 +115,7 @@ Rtabmap::Rtabmap() :
_memory(0),
_foutFloat(0),
_foutInt(0),
_wDir(std::string(".")+UDirectory::separator()),
_wDir("."),
_mapCorrection(Transform::getIdentity()),
_mapTransform(Transform::getIdentity())
{
@@ -158,15 +158,15 @@ void Rtabmap::setupLogFiles(bool overwrite)
attributes = "w";
}
bool addLogFHeader = overwrite || !UFile::exists(_wDir+LOG_F);
bool addLogIHeader = overwrite || !UFile::exists(_wDir+LOG_I);
bool addLogFHeader = overwrite || !UFile::exists(_wDir+"/"+LOG_F);
bool addLogIHeader = overwrite || !UFile::exists(_wDir+"/"+LOG_I);
#ifdef _MSC_VER
fopen_s(&_foutFloat, (_wDir+LOG_F).c_str(), attributes.c_str());
fopen_s(&_foutInt, (_wDir+LOG_I).c_str(), attributes.c_str());
fopen_s(&_foutFloat, (_wDir+"/"+LOG_F).c_str(), attributes.c_str());
fopen_s(&_foutInt, (_wDir+"/"+LOG_I).c_str(), attributes.c_str());
#else
_foutFloat = fopen((_wDir+LOG_F).c_str(), attributes.c_str());
_foutInt = fopen((_wDir+LOG_I).c_str(), attributes.c_str());
_foutFloat = fopen((_wDir+"/"+LOG_F).c_str(), attributes.c_str());
_foutInt = fopen((_wDir+"/"+LOG_I).c_str(), attributes.c_str());
#endif
// add header (column identification)
if(_statisticLoggedHeaders && addLogFHeader && _foutFloat)
@@ -215,8 +215,8 @@ void Rtabmap::setupLogFiles(bool overwrite)
fprintf(_foutInt, " 17-Is last location merged through Weight Update?\n");
}
ULOGGER_DEBUG("Log file (int)=%s", (_wDir+LOG_I).c_str());
ULOGGER_DEBUG("Log file (float)=%s", (_wDir+LOG_F).c_str());
ULOGGER_DEBUG("Log file (int)=%s", (_wDir+"/"+LOG_I).c_str());
ULOGGER_DEBUG("Log file (float)=%s", (_wDir+"/"+LOG_F).c_str());
}
else
{
@@ -257,7 +257,7 @@ void Rtabmap::init(const ParametersMap & parameters, const std::string & databas
_databasePath = databasePath;
if(_databasePath.empty())
{
_databasePath = _wDir + Parameters::getDefaultDatabaseName();
_databasePath = _wDir + "/" + Parameters::getDefaultDatabaseName();
}
UINFO("Using database \"%s\".", _databasePath.c_str());
this->parseParameters(parameters);
@@ -1775,11 +1775,6 @@ void Rtabmap::setTimeThreshold(float maxTimeAllowed)
void Rtabmap::setWorkingDirectory(std::string path)
{
if(path.size() && (path.at(path.size()-1) != '\\' || path.at(path.size()-1) != '/' ))
{
path += UDirectory::separator();
}
if(!path.empty() && UDirectory::exists(path))
{
ULOGGER_DEBUG("Comparing new working directory path \"%s\" with \"%s\"", path.c_str(), _wDir.c_str());
+1 -1
View File
@@ -97,7 +97,7 @@ int main(int argc, char * argv[])
// Appearance-based only, disable RGB-D mode
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kRGBDEnabled(), "false"));
std::string databasePath = rtabmap::Parameters::defaultRtabmapWorkingDirectory()+rtabmap::Parameters::getDefaultDatabaseName();
std::string databasePath = rtabmap::Parameters::defaultRtabmapWorkingDirectory()+"/"+rtabmap::Parameters::getDefaultDatabaseName();
if(localizationMode)
{
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kMemIncrementalMemory(), "false"));
+15 -16
View File
@@ -1441,10 +1441,10 @@ void MainWindow::processRtabmapEventInit(int status, const QString & info)
else if((RtabmapEventInit::Status)status == RtabmapEventInit::kClosed)
{
_initProgressDialog->setValue(_initProgressDialog->maximumSteps());
if(_openedDatabasePath.compare(_preferencesDialog->getWorkingDirectory()+"/"+Parameters::getDefaultDatabaseName().c_str()) == 0)
if(_openedDatabasePath.compare(_preferencesDialog->getWorkingDirectory()+QDir::separator()+Parameters::getDefaultDatabaseName().c_str()) == 0)
{
// Temp database used, automatically backup with unique name (timestamp)
QString newName = _preferencesDialog->getWorkingDirectory()+(QString("/rtabmap_%1.db").arg(QDateTime::currentDateTime().toString("yyMMddhhmmss")));
QString newName = _preferencesDialog->getWorkingDirectory()+QDir::separator()+(QString("rtabmap_%1.db").arg(QDateTime::currentDateTime().toString("yyMMdd-hhmmsszzz")));
if(QFile::rename(_openedDatabasePath, newName))
{
std::string msg = uFormat("Database saved to \"%s\".", newName.toStdString().c_str());
@@ -1609,7 +1609,7 @@ void MainWindow::applyPrefSettings(PreferencesDialog::PANEL_FLAGS flags)
ULogger::setLevel((ULogger::Level)_preferencesDialog->getGeneralLoggerLevel());
ULogger::setEventLevel((ULogger::Level)_preferencesDialog->getGeneralLoggerEventLevel());
ULogger::setType((ULogger::Type)_preferencesDialog->getGeneralLoggerType(),
((_preferencesDialog->getWorkingDirectory()+"/")+LOG_FILE_NAME).toStdString(), true);
(_preferencesDialog->getWorkingDirectory()+QDir::separator()+LOG_FILE_NAME).toStdString(), true);
ULogger::setPrintTime(_preferencesDialog->getGeneralLoggerPrintTime());
}
}
@@ -1895,19 +1895,19 @@ void MainWindow::changeMappingMode()
void MainWindow::captureScreen()
{
QString targetDir = _preferencesDialog->getWorkingDirectory() + "/ScreensCaptured";
QString targetDir = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "ScreensCaptured";
QDir dir;
if(!dir.exists(targetDir))
{
dir.mkdir(targetDir);
}
targetDir += "/";
targetDir += QDir::separator();
targetDir += "Main_window";
if(!dir.exists(targetDir))
{
dir.mkdir(targetDir);
}
targetDir += "/";
targetDir += QDir::separator();
QString name = (QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".png");
_ui->statusbar->clearMessage();
QPixmap figure = QPixmap::grabWidget(this);
@@ -1933,7 +1933,7 @@ void MainWindow::newDatabase()
_openedDatabasePath.clear();
ULOGGER_DEBUG("");
this->clearTheCache();
std::string databasePath = _preferencesDialog->getWorkingDirectory().toStdString()+"/"+Parameters::getDefaultDatabaseName();
std::string databasePath = (_preferencesDialog->getWorkingDirectory()+QDir::separator()+Parameters::getDefaultDatabaseName().c_str()).toStdString();
if(QFile::exists(databasePath.c_str()))
{
if(QFile::remove(databasePath.c_str()))
@@ -2421,7 +2421,7 @@ void MainWindow::generateMap()
{
if(_graphSavingFileName.isEmpty())
{
_graphSavingFileName = _preferencesDialog->getWorkingDirectory() + "/Graph.dot";
_graphSavingFileName = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "Graph.dot";
}
QString path = QFileDialog::getSaveFileName(this, tr("Save File"), _graphSavingFileName, tr("Graphiz file (*.dot)"));
if(!path.isEmpty())
@@ -2438,7 +2438,7 @@ void MainWindow::generateLocalMap()
{
if(_graphSavingFileName.isEmpty())
{
_graphSavingFileName = _preferencesDialog->getWorkingDirectory() + "/Graph.dot";
_graphSavingFileName = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "Graph.dot";
}
bool ok = false;
@@ -2480,7 +2480,7 @@ void MainWindow::generateTOROMap()
{
if(_toroSavingFileName.isEmpty())
{
_toroSavingFileName = _preferencesDialog->getWorkingDirectory() + "/toro.graph";
_toroSavingFileName = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "toro.graph";
}
QStringList items;
@@ -2596,10 +2596,9 @@ void MainWindow::openWorkingDirectory()
void MainWindow::updateEditMenu()
{
// Update Memory delete database size
if(_state != kMonitoring && _state != kMonitoringPaused)
if(_state != kMonitoring && _state != kMonitoringPaused && !_openedDatabasePath.isEmpty())
{
QString dbPath = _preferencesDialog->getWorkingDirectory() + "/rtabmap.db";
_ui->actionDelete_memory->setText(tr("Delete memory (%1 MB)").arg(UFile::length(dbPath.toStdString())/1000000));
_ui->actionDelete_memory->setText(tr("Delete memory (%1 MB)").arg(UFile::length(_openedDatabasePath.toStdString())/1000000));
}
}
@@ -3442,7 +3441,7 @@ void MainWindow::saveClouds(const std::map<int, pcl::PointCloud<pcl::PointXYZRGB
{
if(clouds.size() == 1)
{
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+"/cloud.ply", tr("Point cloud data (*.ply *.pcd)"));
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+QDir::separator()+"cloud.ply", tr("Point cloud data (*.ply *.pcd)"));
if(!path.isEmpty())
{
if(clouds.begin()->second->size())
@@ -3550,7 +3549,7 @@ void MainWindow::saveMeshes(const std::map<int, pcl::PolygonMesh::Ptr> & meshes)
{
if(meshes.size() == 1)
{
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+"/mesh.ply", tr("Mesh (*.ply)"));
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+QDir::separator()+"mesh.ply", tr("Mesh (*.ply)"));
if(!path.isEmpty())
{
if(meshes.begin()->second->polygons.size())
@@ -3649,7 +3648,7 @@ void MainWindow::saveScans(const std::map<int, pcl::PointCloud<pcl::PointXYZ>::P
{
if(scans.size() == 1)
{
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+"/scan.ply", tr("Point cloud data (*.ply *.pcd)"));
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+QDir::separator()+"scan.ply", tr("Point cloud data (*.ply *.pcd)"));
if(!path.isEmpty())
{
if(scans.begin()->second->size())
+1 -1
View File
@@ -1191,7 +1191,7 @@ bool PreferencesDialog::readCoreSettings(const QString & filePath)
bool PreferencesDialog::saveConfigTo()
{
QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), this->getWorkingDirectory()+"/config.ini", "*.ini");
QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), this->getWorkingDirectory()+QDir::separator()+"config.ini", "*.ini");
if(!path.isEmpty())
{
this->writeSettings(path);