BlinkenArea - GitList
Repositories
Blog
Wiki
dxfngc
Code
Commits
Branches
Tags
Search
Tree:
be85cfc
Branches
Tags
master
dxfngc
src
filename.cpp
initial version, DXFs can be read, some G-code can be produced
Stefan Schuermans
commited
be85cfc
at 2013-01-20 20:53:53
filename.cpp
Blame
History
Raw
/* drawing (DXF) to G-code (NGC) converter * Copyright 2013 Stefan Schuermans <stefan@schuermans.info> * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/ */ #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; }