From 108ce38443eda81032b72e81202237da53f922e8 Mon Sep 17 00:00:00 2001 From: Vincent Bénony Date: Tue, 1 Dec 2015 18:53:52 +0100 Subject: IOS: Added a chroot like filesystem This is needed because it is not possible to keep absolute paths to the iOS document directory, because a part of its name change between each installation / update. --- common/fs.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/fs.h b/common/fs.h index b5b88ba8cb..e6f2fe18fe 100644 --- a/common/fs.h +++ b/common/fs.h @@ -58,10 +58,11 @@ class FSList : public Array {}; class FSNode : public ArchiveMember { private: SharedPtr _realNode; - FSNode(AbstractFSNode *realNode); public: - /** + FSNode(AbstractFSNode *realNode); + + /** * Flag to tell listDir() which kind of files to list. */ enum ListMode { -- cgit v1.2.3 From bbf3785bbadd42536ad6a266ae4dc082351f87d5 Mon Sep 17 00:00:00 2001 From: Vincent Bénony Date: Tue, 1 Dec 2015 18:57:39 +0100 Subject: IOS: Adds two helper functions on strings --- common/str.cpp | 12 ++++++++++++ common/str.h | 6 ++++++ 2 files changed, 18 insertions(+) (limited to 'common') diff --git a/common/str.cpp b/common/str.cpp index faf84d722f..ad02bfdaf8 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -665,6 +665,18 @@ String lastPathComponent(const String &path, const char sep) { return String(first, last); } +String String::stringByAppendingPathComponent(String component, char sep) const { + if (lastChar() == sep && component.firstChar() == sep) { + return String::format("%s%s", c_str(), component.c_str() + 1); + } + + if (lastChar() == sep || component.firstChar() == sep) { + return String::format("%s%s", c_str(), component.c_str()); + } + + return String::format("%s%c%s", c_str(), sep, component.c_str()); +} + String normalizePath(const String &path, const char sep) { if (path.empty()) return path; diff --git a/common/str.h b/common/str.h index dede87a005..f156290e94 100644 --- a/common/str.h +++ b/common/str.h @@ -180,6 +180,7 @@ public: inline uint size() const { return _size; } inline bool empty() const { return (_size == 0); } + char firstChar() const { return (_size > 0) ? _str[0] : 0; } char lastChar() const { return (_size > 0) ? _str[_size - 1] : 0; } char operator[](int idx) const { @@ -217,6 +218,11 @@ public: */ void trim(); + /** + * Add a path component + */ + String stringByAppendingPathComponent(String component, char sep = '/') const; + uint hash() const; /** -- cgit v1.2.3 From 16605a3e1062efe96d1f647a93ddda379c77f453 Mon Sep 17 00:00:00 2001 From: Vincent Bénony Date: Wed, 6 Jan 2016 15:43:42 +0100 Subject: IOS: Moves the helper function were it is used. --- common/str.cpp | 12 ------------ common/str.h | 5 ----- 2 files changed, 17 deletions(-) (limited to 'common') diff --git a/common/str.cpp b/common/str.cpp index ad02bfdaf8..faf84d722f 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -665,18 +665,6 @@ String lastPathComponent(const String &path, const char sep) { return String(first, last); } -String String::stringByAppendingPathComponent(String component, char sep) const { - if (lastChar() == sep && component.firstChar() == sep) { - return String::format("%s%s", c_str(), component.c_str() + 1); - } - - if (lastChar() == sep || component.firstChar() == sep) { - return String::format("%s%s", c_str(), component.c_str()); - } - - return String::format("%s%c%s", c_str(), sep, component.c_str()); -} - String normalizePath(const String &path, const char sep) { if (path.empty()) return path; diff --git a/common/str.h b/common/str.h index f156290e94..a30dae3513 100644 --- a/common/str.h +++ b/common/str.h @@ -218,11 +218,6 @@ public: */ void trim(); - /** - * Add a path component - */ - String stringByAppendingPathComponent(String component, char sep = '/') const; - uint hash() const; /** -- cgit v1.2.3 From e0bfdb41d0b4d935cb9a5e08b6506adfac5f7af0 Mon Sep 17 00:00:00 2001 From: Vincent Bénony Date: Wed, 6 Jan 2016 10:45:25 +0100 Subject: IOS: Formatting --- common/fs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/fs.h b/common/fs.h index e6f2fe18fe..b7442bb6c7 100644 --- a/common/fs.h +++ b/common/fs.h @@ -60,9 +60,9 @@ private: SharedPtr _realNode; public: - FSNode(AbstractFSNode *realNode); + FSNode(AbstractFSNode *realNode); - /** + /** * Flag to tell listDir() which kind of files to list. */ enum ListMode { -- cgit v1.2.3 From 73385584ba08a4acbdc81503ff9c4749d59657d9 Mon Sep 17 00:00:00 2001 From: Vincent Bénony Date: Wed, 6 Jan 2016 10:46:46 +0100 Subject: IOS: Adds a warning --- common/fs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/fs.h b/common/fs.h index b7442bb6c7..66e98444d6 100644 --- a/common/fs.h +++ b/common/fs.h @@ -60,6 +60,7 @@ private: SharedPtr _realNode; public: + // WARNING: Use this constructor with care! FSNode takes the ownership of the pointer and will delete it at some point. FSNode(AbstractFSNode *realNode); /** -- cgit v1.2.3