summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/putil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/plib/putil.cpp')
-rw-r--r--src/lib/netlist/plib/putil.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/lib/netlist/plib/putil.cpp b/src/lib/netlist/plib/putil.cpp
index b4824d62738..f6eed734a3e 100644
--- a/src/lib/netlist/plib/putil.cpp
+++ b/src/lib/netlist/plib/putil.cpp
@@ -13,6 +13,32 @@ namespace plib
{
namespace util
{
+ #ifdef _WIN32
+ static constexpr const char PATH_SEP = '\\';
+ #else
+ static constexpr const char PATH_SEP = '/';
+ #endif
+
+ pstring basename(pstring filename)
+ {
+ auto p=find_last_of(filename, pstring(1, PATH_SEP));
+ if (p == pstring::npos)
+ return filename;
+ else
+ return filename.substr(p+1);
+ }
+
+ pstring path(pstring filename)
+ {
+ auto p=find_last_of(filename, pstring(1, PATH_SEP));
+ if (p == pstring::npos)
+ return "";
+ else if (p == 0) // root case
+ return filename.substr(0, 1);
+ else
+ return filename.substr(0, p);
+ }
+
pstring buildpath(std::initializer_list<pstring> list )
{
pstring ret = "";
@@ -21,11 +47,7 @@ namespace plib
if (ret == "")
ret = elem;
else
- #ifdef _WIN32
- ret = ret + '\\' + elem;
- #else
- ret += ('/' + elem);
- #endif
+ ret += (PATH_SEP + elem);
}
return ret;
}