From 9f7ff84fe4b9362a80ccf6b0f40602e01fb991d1 Mon Sep 17 00:00:00 2001 From: richiesams Date: Tue, 16 Jul 2013 16:55:18 -0500 Subject: ZVISION: Create utility function to parse fileName from a full/partial path --- engines/zvision/utility.cpp | 19 +++++++++++++++++++ engines/zvision/utility.h | 2 ++ 2 files changed, 21 insertions(+) (limited to 'engines/zvision') 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 *container) { } } +Common::String getFileName(const Common::String &fullPath); + } // End of namespace ZVision #endif -- cgit v1.2.3