diff options
author | Vincent Bénony | 2016-01-06 15:43:42 +0100 |
---|---|---|
committer | Vincent Bénony | 2016-01-06 16:20:29 +0100 |
commit | 16605a3e1062efe96d1f647a93ddda379c77f453 (patch) | |
tree | 4c3531101de60bd87a952d77f462e56df1bdd339 /backends/fs/chroot | |
parent | a56c58765191f17180f612d69a4c4bf8d3c13233 (diff) | |
download | scummvm-rg350-16605a3e1062efe96d1f647a93ddda379c77f453.tar.gz scummvm-rg350-16605a3e1062efe96d1f647a93ddda379c77f453.tar.bz2 scummvm-rg350-16605a3e1062efe96d1f647a93ddda379c77f453.zip |
IOS: Moves the helper function were it is used.
Diffstat (limited to 'backends/fs/chroot')
-rw-r--r-- | backends/fs/chroot/chroot-fs.cpp | 15 | ||||
-rw-r--r-- | backends/fs/chroot/chroot-fs.h | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/backends/fs/chroot/chroot-fs.cpp b/backends/fs/chroot/chroot-fs.cpp index 7cdd800dac..1c3e3b545f 100644 --- a/backends/fs/chroot/chroot-fs.cpp +++ b/backends/fs/chroot/chroot-fs.cpp @@ -39,7 +39,7 @@ ChRootFilesystemNode::ChRootFilesystemNode(const Common::String &root, POSIXFile ChRootFilesystemNode::ChRootFilesystemNode(const Common::String &root, const Common::String &path) { _root = Common::normalizePath(root, '/'); - _realNode = new POSIXFilesystemNode(root.stringByAppendingPathComponent(path)); + _realNode = new POSIXFilesystemNode(addPathComponent(root, path)); } ChRootFilesystemNode::~ChRootFilesystemNode() { @@ -108,4 +108,17 @@ Common::WriteStream *ChRootFilesystemNode::createWriteStream() { return _realNode->createWriteStream(); } +Common::String ChRootFilesystemNode::addPathComponent(const Common::String &path, const Common::String &component) { + const char sep = '/'; + if (path.lastChar() == sep && component.firstChar() == sep) { + return Common::String::format("%s%s", path.c_str(), component.c_str() + 1); + } + + if (path.lastChar() == sep || component.firstChar() == sep) { + return Common::String::format("%s%s", path.c_str(), component.c_str()); + } + + return Common::String::format("%s%c%s", path.c_str(), sep, component.c_str()); +} + #endif diff --git a/backends/fs/chroot/chroot-fs.h b/backends/fs/chroot/chroot-fs.h index 2d4c3eb9dd..c330123bb5 100644 --- a/backends/fs/chroot/chroot-fs.h +++ b/backends/fs/chroot/chroot-fs.h @@ -49,6 +49,9 @@ public: virtual Common::SeekableReadStream *createReadStream(); virtual Common::WriteStream *createWriteStream(); + +private: + static Common::String addPathComponent(const Common::String &path, const Common::String &component); }; #endif /* CHROOT_FS_H */ |