mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-23 14:33:36 +00:00
Merge pull request #209 from Acemany/fix-file-delimeter
fix File class' delimeter and homepath detection
This commit is contained in:
commit
f4d8815285
|
|
@ -485,49 +485,41 @@ void Minecraft::blit(int x, int y, int sx, int sy, int w, int h)
|
|||
|
||||
File Minecraft::getWorkingDirectory()
|
||||
{
|
||||
if (workDir.getPath().empty()) workDir = getWorkingDirectory(L"minecraft");
|
||||
if (workDir.getPath().empty()) workDir = getWorkingDirectory(L"4jcraft");
|
||||
return workDir;
|
||||
}
|
||||
|
||||
File Minecraft::getWorkingDirectory(const std::wstring& applicationName)
|
||||
{
|
||||
#if 0
|
||||
// 4J - original version
|
||||
final String userHome = System.getProperty("user.home", ".");
|
||||
final File workingDirectory;
|
||||
switch (getPlatform()) {
|
||||
case linux:
|
||||
case solaris:
|
||||
workingDirectory = new File(userHome, '.' + applicationName + '/');
|
||||
break;
|
||||
case windows:
|
||||
final String applicationData = System.getenv("APPDATA");
|
||||
if (applicationData != null) workingDirectory = new File(applicationData, "." + applicationName + '/');
|
||||
else workingDirectory = new File(userHome, '.' + applicationName + '/');
|
||||
break;
|
||||
case macos:
|
||||
workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
|
||||
break;
|
||||
default:
|
||||
workingDirectory = new File(userHome, applicationName + '/');
|
||||
// 4jcraft: ported to C++
|
||||
std::wstring userHome = convStringToWstring(getenv("HOME"));
|
||||
File *workingDirectory;
|
||||
#if defined(__linux__)
|
||||
workingDirectory = new File(userHome, L'.' + applicationName + L'/');
|
||||
#elif defined(_WINDOWS64)
|
||||
std::string applicationData = getenv("APPDATA");
|
||||
if (!applicationData.empty())
|
||||
{
|
||||
workingDirectory = new File(convStringToWstring(applicationData), L'.' + applicationName + L'/');
|
||||
}
|
||||
if (!workingDirectory.exists()) if (!workingDirectory.mkdirs()) throw new RuntimeException("The working directory could not be created: " + workingDirectory);
|
||||
return workingDirectory;
|
||||
else
|
||||
{
|
||||
workingDirectory = new File(userHome, L'.' + applicationName + L'/');
|
||||
}
|
||||
//#elif defined(_MACOS)
|
||||
// workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
|
||||
#else
|
||||
std::wstring userHome = L"home"; // 4J - TODO
|
||||
File workingDirectory(userHome, applicationName);
|
||||
// 4J Removed
|
||||
//if (!workingDirectory.exists())
|
||||
//{
|
||||
// workingDirectory.mkdirs();
|
||||
//}
|
||||
return workingDirectory;
|
||||
workingDirectory = new File(userHome, applicationName + L'/');
|
||||
#endif
|
||||
}
|
||||
|
||||
Minecraft::OS Minecraft::getPlatform()
|
||||
{
|
||||
return xbox;
|
||||
if (!workingDirectory->exists()){
|
||||
if (!workingDirectory->mkdirs()) {
|
||||
app.DebugPrintf("The working directory could not be created");
|
||||
assert(0);
|
||||
//throw new RuntimeException(L"The working directory could not be created: " + workingDirectory);
|
||||
}
|
||||
}
|
||||
return *workingDirectory;
|
||||
}
|
||||
|
||||
LevelStorageSource *Minecraft::getLevelSource()
|
||||
|
|
|
|||
|
|
@ -50,11 +50,6 @@ class PsPlusUpsellWrapper;
|
|||
|
||||
class Minecraft
|
||||
{
|
||||
private:
|
||||
enum OS{
|
||||
linux, solaris, windows, macos, unknown, xbox
|
||||
};
|
||||
|
||||
public:
|
||||
static const std::wstring VERSION_STRING;
|
||||
Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet *minecraftApplet, int width, int height, bool fullscreen);
|
||||
|
|
@ -200,8 +195,6 @@ private:
|
|||
public:
|
||||
static File getWorkingDirectory();
|
||||
static File getWorkingDirectory(const std::wstring& applicationName);
|
||||
private:
|
||||
static OS getPlatform();
|
||||
public:
|
||||
LevelStorageSource *getLevelSource();
|
||||
void setScreen(Screen *screen);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@
|
|||
#include <fios2.h>
|
||||
#endif
|
||||
|
||||
const wchar_t File::pathSeparator = L'\\';
|
||||
const wchar_t File::pathSeparator = L'/';
|
||||
|
||||
#ifdef _XBOX
|
||||
const std::wstring File::pathRoot = L"GAME:"; // Path root after pathSeparator has been removed
|
||||
#else
|
||||
|
|
|
|||
Loading…
Reference in a new issue