ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

riscos-utils.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "common/scummsys.h"
00024 #include "backends/platform/sdl/riscos/riscos-utils.h"
00025 
00026 #include <unixlib/local.h>
00027 #include <limits.h>
00028 
00029 namespace RISCOS_Utils {
00030 
00031 Common::String toRISCOS(Common::String path) {
00032     char start[PATH_MAX];
00033     char *end = __riscosify_std(path.c_str(), 0, start, PATH_MAX, 0);
00034     return Common::String(start, end);
00035 }
00036 
00037 Common::String toUnix(Common::String path) {
00038     Common::String out = Common::String(path);
00039     uint32 start = 0;
00040     if (out.contains("$")) {
00041         char *x = strstr(out.c_str(), "$");
00042         start = x ? x - out.c_str() : -1;
00043     } else if (out.contains(":")) {
00044         char *x = strstr(out.c_str(), ":");
00045         start = x ? x - out.c_str() : -1;
00046     }
00047 
00048     for (uint32 ptr = start; ptr < out.size(); ptr += 1) {
00049         switch (out.c_str()[ptr]) {
00050         case '.':
00051             out.setChar('/', ptr);
00052             break;
00053         case '/':
00054             out.setChar('.', ptr);
00055             break;
00056         case '\xA0':
00057             out.setChar(' ', ptr);
00058             break;
00059         default:
00060             break;
00061         }
00062     }
00063 
00064     if (out.contains("$") || out.contains(":"))
00065         out = "/" + out;
00066 
00067     return out;
00068 }
00069 
00070 }


Generated on Sat May 30 2020 05:00:35 for ResidualVM by doxygen 1.7.1
curved edge   curved edge