Add usage of command line.

This commit is contained in:
sunwen
2023-06-28 16:48:28 +08:00
parent b728b9e204
commit fad9168527
8 changed files with 130 additions and 36 deletions

41
src/common/fileHelper.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include "fileHelper.h"
#include <sys/stat.h>
std::string Recon::getPath(const std::string &aFullPath)
{
size_t pos = aFullPath.find_last_of('/');
if (pos != std::string::npos)
{
return aFullPath.substr(0, pos);
}
return "";
}
bool Recon::endsWithMat(const std::string &aStr)
{
if (aStr.length() >= 4)
{
return (aStr.compare(aStr.length() - 4, 4, ".mat") == 0);
}
return false;
}
bool Recon::isDirectory(const std::string &aPath)
{
struct stat info;
if (stat(aPath.c_str(), &info) != 0)
{
return false;
}
return (info.st_mode & S_IFDIR) != 0;
}
std::string Recon::fixPathSlash(const std::string& aPath)
{
if(aPath.back() == '/')
{
return aPath;
}
return aPath + '/';
}

18
src/common/fileHelper.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef FILE_HELPER_H
#define FILE_HELPER_H
#include <string>
namespace Recon
{
const std::string DEFAULT_CONFIG_PATH = "/home/sun/UR/build/";
const std::string DEFAULT_OUTPUT_PATH = "/home/sun/USCT_Result.mat";
const std::string DEFAULT_OUTPUT_FILENAME = "USCT_Result.mat";
std::string getPath(const std::string &aFullPath);
bool endsWithMat(const std::string &aStr);
bool isDirectory(const std::string &aPath);
std::string fixPathSlash(const std::string& aPath);
}
#endif