BlinkenArea - GitList
Repositories
Blog
Wiki
dxfngc
Code
Commits
Branches
Tags
Search
Tree:
1030916
Branches
Tags
master
dxfngc
src
filename.cpp
license CC-BY-SA --> GPL (more suitable for source code)
Stefan Schuermans
commited
1030916
at 2013-05-27 17:35:02
filename.cpp
Blame
History
Raw
/* drawing (DXF) to G-code (NGC) converter * Copyright 2013 Stefan Schuermans <stefan@schuermans.info> * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html */ #include <string> #include "filename.h" /** * @brief get directory part of path * @param[in] path full absolute or relative path * @return directory part of file name, ending with a slash or empty */ std::string filename_get_dir(const std::string &path) { // search last slash std::string::size_type ls = path.rfind('/'); // no slash -> empty directory part if (ls == std::string::npos) return ""; // return everything including the slash return path.substr(0, ls + 1); } /** * @brief re-base path * @param[in] path full absolute or relative path to re-base * @param[in] base base dir to re-base path to, ending with a slash or empty * @return re-based path */ std::string filename_rebase(const std::string &path, const std::string &base) { // path is absolute -> do not change it if (path.length() >= 1 && path.at(0) == '/') return path; // prepend base directory to path return base + path; }