Skip to content
Snippets Groups Projects
Commit f5289f19 authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Dmitrij Naumov
Browse files

extractPath() returns result now.

parent 02690a5a
No related branches found
No related tags found
No related merge requests found
......@@ -90,8 +90,7 @@ std::string copyPathToFileName(const std::string &file_name, const std::string &
pos = file_name.rfind("\\"); // windows delimiter
if (pos == std::string::npos)
{
std::string path;
BaseLib::extractPath(source, path);
std::string path = BaseLib::extractPath(source);
return path.append(file_name);
}
else return std::string(file_name);
......@@ -99,16 +98,16 @@ std::string copyPathToFileName(const std::string &file_name, const std::string &
else return std::string(file_name);
}
void extractPath(std::string const& fname, std::string& path)
std::string extractPath(std::string const& pathname)
{
// extract path for reading external files
size_t pos(fname.rfind("/")); // linux, mac delimiter
size_t pos(pathname.rfind("/")); // linux, mac delimiter
if (pos == std::string::npos) {
pos = fname.rfind("\\"); // windows delimiter
pos = pathname.rfind("\\"); // windows delimiter
if (pos == std::string::npos)
pos = 0;
}
path = fname.substr(0, pos==0 ? pos : pos + 1);
return pathname.substr(0, pos==0 ? pos : pos + 1);
}
} // end namespace BaseLib
......
......@@ -64,11 +64,9 @@ std::string getSuffixFromPath(const std::string &str);
std::string copyPathToFileName(const std::string &file_name, const std::string &source);
/**
* extracts the path of a fully qualified path name of the file
* @param fname [input] the fully qualified path name of the file
* @param path [output] the path of the fully qualified path name of the file
* Extracts the path of a pathname.
*/
void extractPath(std::string const& fname, std::string& path);
std::string extractPath(std::string const& pathname);
} // end namespace BaseLib
#endif // FILETOOLS_H
......@@ -556,8 +556,7 @@ bool readGLIFileV4(const std::string& fname, GEOObjects* geo, std::string& uniqu
geo->addPointVec(pnt_vec, unique_name, pnt_id_names_map); // KR: insert into GEOObjects if not empty
// extract path for reading external files
std::string path;
BaseLib::extractPath(fname, path);
const std::string path = BaseLib::extractPath(fname);
// read names of plys into temporary string-vec
std::map<std::string,size_t>* ply_names (new std::map<std::string,size_t>);
......@@ -669,8 +668,7 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects
geo.getGeometryNames (geo_names);
// extract path for reading external files
std::string path;
BaseLib::extractPath(fname, path);
const std::string path = BaseLib::extractPath(fname);
std::ofstream os (fname.c_str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment