Fix save_dir mounting

This commit is contained in:
Rob Loach 2018-10-07 14:16:54 -04:00
parent bcbe88c668
commit 147aaeec82
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A
2 changed files with 16 additions and 4 deletions

View File

@ -4,6 +4,10 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 0.28.1 - Unreleased
### Fixes
- Fixed save_dir mounting
## 0.28.0 - 2018-10-07
### Features
- `love.timer.step()` now returns `dt`

View File

@ -72,8 +72,12 @@ void filesystem::mountlibretro() {
if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &save_dir) && save_dir) {
save_dir = *save_dir ? save_dir : system_dir;
mount(save_dir, "/libretro/saves", false);
} else {
} else if (system_dir) {
// Have the system directory be the save directory if available.
mount(save_dir = system_dir, "/libretro/saves", false);
} else {
// Save directory becomes the current working directory.
mount(save_dir = ".", "/libretro/saves", false);
}
// Ensure the write directory is set to the Save Directory.
@ -171,10 +175,11 @@ char* filesystem::readChar(const std::string& filename) {
std::string filesystem::read(const std::string& filename) {
// Retrieve a character buffer.
char* myBuf = readChar(filename);
if (myBuf == NULL) {
return std::string("");
std::string output;
if (myBuf != NULL) {
output = std::string(myBuf);
}
return std::string(myBuf);
return output;
}
void* filesystem::readBuffer(const std::string& filename, int& size) {
@ -222,6 +227,9 @@ bool filesystem::unmount(const std::string& archive) {
}
bool filesystem::mount(const char *archive, const std::string& mountpoint) {
if (strlen(archive) == 0) {
return false;
}
return mount(std::string(archive), mountpoint);
}