Skip to content
Permalink
Browse files

Make nall/string/filename functions resize their output properly

  • Loading branch information...
Cydrak Cydrak
Cydrak authored and Cydrak committed Aug 4, 2013
1 parent ed3c1e4 commit c2ed70905ee866e59058fd0d8f95c4f34c6ae023
Showing with 3 additions and 3 deletions.
  1. +3 −3 nall/string/filename.hpp
@@ -8,7 +8,7 @@ namespace nall {
inline string dir(string name) {
for(signed i = name.length(); i >= 0; i--) {
if(name[i] == '/' || name[i] == '\\') {
name[i + 1] = 0;
name.resize(i + 1);
break;
}
if(i == 0) name = "./";
@@ -41,7 +41,7 @@ inline string parentdir(string name) {
}
}
if(last + 1 == length) last = prev; //if name ends in slash; use previous slash
if(paths > 1) name[last + 1] = 0;
if(paths > 1) name.resize(last + 1);
return name;
}

@@ -50,7 +50,7 @@ inline string basename(string name) {
for(signed i = name.length(); i >= 0; i--) {
if(name[i] == '/' || name[i] == '\\') break; //file has no extension
if(name[i] == '.') {
name[i] = 0;
name.resize(i);
break;
}
}

0 comments on commit c2ed709

Please sign in to comment.
You can’t perform that action at this time.