aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichiesams2013-07-16 16:55:18 -0500
committerrichiesams2013-08-04 13:32:20 -0500
commit9f7ff84fe4b9362a80ccf6b0f40602e01fb991d1 (patch)
tree56c4e215685cbcfbd30737f43b378dd7a0d3fb20
parenta30f49b556ef27644d752368c11590cc48c0fccf (diff)
downloadscummvm-rg350-9f7ff84fe4b9362a80ccf6b0f40602e01fb991d1.tar.gz
scummvm-rg350-9f7ff84fe4b9362a80ccf6b0f40602e01fb991d1.tar.bz2
scummvm-rg350-9f7ff84fe4b9362a80ccf6b0f40602e01fb991d1.zip
ZVISION: Create utility function to parse fileName from a full/partial path
-rw-r--r--engines/zvision/utility.cpp19
-rw-r--r--engines/zvision/utility.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp
index 41b589d0c0..5f69fd7433 100644
--- a/engines/zvision/utility.cpp
+++ b/engines/zvision/utility.cpp
@@ -22,6 +22,8 @@
#include "common/scummsys.h"
+#include "common/tokenizer.h"
+
#include "zvision/utility.h"
namespace ZVision {
@@ -177,4 +179,21 @@ void dumpEveryResultAction(const Common::String &destFile) {
output.close();
}
+/**
+ * Gets the name of the file (including extension). Forward or back slashes
+ * are interpreted as directory changes
+ *
+ * @param fullPath A full or partial path to the file. Ex: folderOne/folderTwo/file.txt
+ * @return The name of the file without any preceding directories. Ex: file.txt
+ */
+Common::String getFileName(const Common::String &fullPath) {
+ Common::StringTokenizer tokenizer(fullPath, "/\\");
+ Common::String token;
+ while (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ }
+
+ return token;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index e5713fc7f4..dba765b65c 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -73,6 +73,8 @@ void removeDuplicateEntries(Common::Array<T> *container) {
}
}
+Common::String getFileName(const Common::String &fullPath);
+
} // End of namespace ZVision
#endif