aboutsummaryrefslogtreecommitdiff
path: root/backends/fs
diff options
context:
space:
mode:
Diffstat (limited to 'backends/fs')
-rw-r--r--backends/fs/riscos/riscos-fs.cpp52
-rw-r--r--backends/fs/riscos/riscos-fs.h18
2 files changed, 7 insertions, 63 deletions
diff --git a/backends/fs/riscos/riscos-fs.cpp b/backends/fs/riscos/riscos-fs.cpp
index 7ee20e7c0a..6f195691a0 100644
--- a/backends/fs/riscos/riscos-fs.cpp
+++ b/backends/fs/riscos/riscos-fs.cpp
@@ -26,6 +26,7 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
+#include "backends/platform/sdl/riscos/riscos-utils.h"
#include "backends/fs/riscos/riscos-fs.h"
#include "backends/fs/stdiostream.h"
#include "common/algorithm.h"
@@ -57,7 +58,7 @@ RISCOSFilesystemNode::RISCOSFilesystemNode(const Common::String &p) {
_isDirectory = true;
_isValid = true;
} else {
- int type = _swi(OS_File, _INR(0,1)|_RETURN(0), 20, toRISCOS(_path).c_str());
+ int type = _swi(OS_File, _INR(0,1)|_RETURN(0), 20, RISCOS_Utils::toRISCOS(_path).c_str());
if (type == 0) {
_isDirectory = false;
_isValid = false;
@@ -71,45 +72,6 @@ RISCOSFilesystemNode::RISCOSFilesystemNode(const Common::String &p) {
}
}
-Common::String RISCOSFilesystemNode::toRISCOS(Common::String &path) {
- char start[PATH_MAX];
- char *end = __riscosify_std(path.c_str(), 0, start, PATH_MAX, 0);
- return Common::String(start, end);
-}
-
-Common::String RISCOSFilesystemNode::toUnix(Common::String &path) {
- Common::String out = Common::String(path);
- uint32 start = 0;
- if (out.contains("$")) {
- char *x = strstr(out.c_str(), "$");
- start = x ? x - out.c_str() : -1;
- } else if (out.contains(":")) {
- char *x = strstr(out.c_str(), ":");
- start = x ? x - out.c_str() : -1;
- }
-
- for (uint32 ptr = start; ptr < out.size(); ptr += 1) {
- switch (out.c_str()[ptr]) {
- case '.':
- out.setChar('/', ptr);
- break;
- case '/':
- out.setChar('.', ptr);
- break;
- case '\xA0':
- out.setChar(' ', ptr);
- break;
- default:
- break;
- }
- }
-
- if (out.contains("$") || out.contains(":"))
- out = "/" + out;
-
- return out;
-}
-
AbstractFSNode *RISCOSFilesystemNode::getChild(const Common::String &n) const {
assert(!_path.empty());
assert(_isDirectory);
@@ -169,7 +131,7 @@ bool RISCOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bo
Common::String dir = _path;
while (count != -1) {
- _swix(OS_GBPB, _INR(0,5)|_OUTR(3,4), 9, toRISCOS(dir).c_str(), file, 1, count, sizeof(file), &read, &count);
+ _swix(OS_GBPB, _INR(0,5)|_OUTR(3,4), 9, RISCOS_Utils::toRISCOS(dir).c_str(), file, 1, count, sizeof(file), &read, &count);
if (count == -1)
continue;
@@ -177,12 +139,12 @@ bool RISCOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bo
// Start with a clone of this node, with the correct path set
RISCOSFilesystemNode entry(*this);
entry._displayName = file;
- entry._displayName = toUnix(entry._displayName);
+ entry._displayName = RISCOS_Utils::toUnix(entry._displayName);
if (_path.lastChar() != '/')
entry._path += '/';
entry._path += entry._displayName;
- int type = _swi(OS_File, _INR(0,1)|_RETURN(0), 20, toRISCOS(entry._path).c_str());
+ int type = _swi(OS_File, _INR(0,1)|_RETURN(0), 20, RISCOS_Utils::toRISCOS(entry._path).c_str());
if (type == 0) {
continue;
} else if (type == 2) {
@@ -240,7 +202,7 @@ bool RISCOSFilesystemNode::create(bool isDirectoryFlag) {
bool success;
if (isDirectoryFlag) {
- success = _swix(OS_File, _INR(0,1), 8, toRISCOS(_path).c_str()) == NULL;
+ success = _swix(OS_File, _INR(0,1), 8, RISCOS_Utils::toRISCOS(_path).c_str()) == NULL;
} else {
int fd = open(_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0755);
success = fd >= 0;
@@ -252,7 +214,7 @@ bool RISCOSFilesystemNode::create(bool isDirectoryFlag) {
if (success) {
if (exists()) {
- _isDirectory = _swi(OS_File, _INR(0,1)|_RETURN(0), 20, toRISCOS(_path).c_str()) == 2;
+ _isDirectory = _swi(OS_File, _INR(0,1)|_RETURN(0), 20, RISCOS_Utils::toRISCOS(_path).c_str()) == 2;
if (_isDirectory != isDirectoryFlag) warning("failed to create %s: got %s", isDirectoryFlag ? "directory" : "file", _isDirectory ? "directory" : "file");
return _isDirectory == isDirectoryFlag;
}
diff --git a/backends/fs/riscos/riscos-fs.h b/backends/fs/riscos/riscos-fs.h
index b02f30bce7..99fa1d59be 100644
--- a/backends/fs/riscos/riscos-fs.h
+++ b/backends/fs/riscos/riscos-fs.h
@@ -68,24 +68,6 @@ public:
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
virtual bool create(bool isDirectoryFlag);
-
-private:
- /**
- * Converts a Unix style path to a RISC OS style path.
- *
- * @param str Unix style path to convert.
- * @return RISC OS style path.
- */
- static Common::String toRISCOS(Common::String &path);
-
- /**
- * Converts a RISC OS style path to a Unix style path.
- *
- * @param str RISC OS style path to convert.
- * @return Unix style path.
- */
- static Common::String toUnix(Common::String &path);
-
};
namespace Riscos {