projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Moved tinygettext to tinygettext.googlecode.com
[supertux.git]
/
src
/
file_system.cpp
diff --git
a/src/file_system.cpp
b/src/file_system.cpp
index
e5721dc
..
447c21e
100644
(file)
--- a/
src/file_system.cpp
+++ b/
src/file_system.cpp
@@
-32,9
+32,9
@@
namespace FileSystem
std::string dirname(const std::string& filename)
{
std::string::size_type p = filename.find_last_of('/');
std::string dirname(const std::string& filename)
{
std::string::size_type p = filename.find_last_of('/');
- if(p == std::string::npos)
+ if(p == std::string::npos)
return "";
return "";
-
+
return filename.substr(0, p+1);
}
return filename.substr(0, p+1);
}
@@
-47,6
+47,15
@@
std::string basename(const std::string& filename)
return filename.substr(p+1, filename.size()-p-1);
}
return filename.substr(p+1, filename.size()-p-1);
}
+std::string strip_extension(const std::string& filename)
+{
+ std::string::size_type p = filename.find_last_of('.');
+ if(p == std::string::npos)
+ return filename;
+
+ return filename.substr(0, p);
+}
+
std::string normalize(const std::string& filename)
{
std::vector<std::string> path_stack;
std::string normalize(const std::string& filename)
{
std::vector<std::string> path_stack;
@@
-67,16
+76,16
@@
std::string normalize(const std::string& filename)
size_t len = p - pstart;
if(len == 0)
break;
size_t len = p - pstart;
if(len == 0)
break;
-
+
std::string pathelem(pstart, p-pstart);
if(pathelem == ".")
continue;
std::string pathelem(pstart, p-pstart);
if(pathelem == ".")
continue;
-
+
if(pathelem == "..") {
if(path_stack.empty()) {
log_warning << "Invalid '..' in path '" << filename << "'" << std::endl;
if(pathelem == "..") {
if(path_stack.empty()) {
log_warning << "Invalid '..' in path '" << filename << "'" << std::endl;
- // push it into the result path so that the user
s
sees his error...
+ // push it into the result path so that the user sees his error...
path_stack.push_back(pathelem);
} else {
path_stack.pop_back();
path_stack.push_back(pathelem);
} else {
path_stack.pop_back();
@@
-99,4
+108,3
@@
std::string normalize(const std::string& filename)
}
}
}
}
-