aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devtools/create_project/create_project.cpp6
-rw-r--r--devtools/create_project/create_project.h11
2 files changed, 17 insertions, 0 deletions
diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp
index b450dafd01..2faf39a340 100644
--- a/devtools/create_project/create_project.cpp
+++ b/devtools/create_project/create_project.cpp
@@ -1056,6 +1056,12 @@ void splitFilename(const std::string &fileName, std::string &name, std::string &
ext = (dot == std::string::npos) ? std::string() : fileName.substr(dot + 1);
}
+std::string basename(const std::string &fileName) {
+ const std::string::size_type slash = fileName.find_last_of('/');
+ if (slash == std::string::npos) return fileName;
+ return fileName.substr(slash + 1);
+}
+
bool producesObjectFile(const std::string &fileName) {
std::string n, ext;
splitFilename(fileName, n, ext);
diff --git a/devtools/create_project/create_project.h b/devtools/create_project/create_project.h
index b81576d4ed..fdcc629382 100644
--- a/devtools/create_project/create_project.h
+++ b/devtools/create_project/create_project.h
@@ -316,6 +316,17 @@ std::string convertPathToWin(const std::string &path);
void splitFilename(const std::string &fileName, std::string &name, std::string &ext);
/**
+ * Returns the basename of a path.
+ * examples:
+ * a/b/c/d.ext -> d.ext
+ * d.ext -> d.ext
+ *
+ * @param fileName Filename
+ * @return The basename
+ */
+std::string basename(const std::string &fileName);
+
+/**
* Checks whether the given file will produce an object file or not.
*
* @param fileName Name of the file.