mirror of https://github.com/axmolengine/axmol.git
Merge pull request #252 from halx99/fix-userdefault-bool
fix userdefault getBoolForKey incorrect
This commit is contained in:
commit
5a1cf12b84
|
@ -51,29 +51,7 @@ THE SOFTWARE.
|
||||||
#include "yasio/obstream.hpp"
|
#include "yasio/obstream.hpp"
|
||||||
#include "yasio/detail/sz.hpp"
|
#include "yasio/detail/sz.hpp"
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#include "CCFileStream.h"
|
||||||
#define O_READ_FLAGS O_BINARY | O_RDONLY, S_IREAD
|
|
||||||
#define O_WRITE_FLAGS O_CREAT | O_RDWR | O_BINARY, S_IWRITE | S_IREAD
|
|
||||||
#define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR | O_BINARY, S_IWRITE | S_IREAD
|
|
||||||
#define posix_open ::_open
|
|
||||||
#define posix_close ::_close
|
|
||||||
#define posix_lseek ::_lseek
|
|
||||||
#define posix_read ::_read
|
|
||||||
#define posix_write ::_write
|
|
||||||
#define posix_fd2fh(fd) reinterpret_cast<HANDLE>(_get_osfhandle(fd))
|
|
||||||
#define posix_fsetsize(fd, size) ::_chsize(fd, size)
|
|
||||||
#else
|
|
||||||
#define O_READ_FLAGS O_RDONLY, S_IRUSR
|
|
||||||
#define O_WRITE_FLAGS O_CREAT | O_RDWR, S_IRWXU
|
|
||||||
#define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR, S_IRWXU
|
|
||||||
#define posix_open ::open
|
|
||||||
#define posix_close ::close
|
|
||||||
#define posix_lseek ::lseek
|
|
||||||
#define posix_read ::read
|
|
||||||
#define posix_write ::write
|
|
||||||
#define posix_fd2fh(fd) (fd)
|
|
||||||
#define posix_fsetsize(fd, size) ::ftruncate(fd, size), ::lseek(fd, 0, SEEK_SET)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define USER_DEFAULT_PLAIN_MODE 0
|
#define USER_DEFAULT_PLAIN_MODE 0
|
||||||
|
|
||||||
|
@ -168,7 +146,7 @@ bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue)
|
||||||
{
|
{
|
||||||
auto it = this->_values.find(pKey);
|
auto it = this->_values.find(pKey);
|
||||||
if (it != this->_values.end())
|
if (it != this->_values.end())
|
||||||
return it->second == "1";
|
return it->second == "true";
|
||||||
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -381,7 +359,7 @@ void UserDefault::init()
|
||||||
|
|
||||||
#if !USER_DEFAULT_PLAIN_MODE
|
#if !USER_DEFAULT_PLAIN_MODE
|
||||||
// construct file mapping
|
// construct file mapping
|
||||||
_fd = posix_open(_filePath.c_str(), O_WRITE_FLAGS);
|
_fd = posix_open(_filePath.c_str(), O_OVERLAP_FLAGS);
|
||||||
if (_fd == -1) {
|
if (_fd == -1) {
|
||||||
log("[Warnning] UserDefault::init open storage file '%s' failed!", _filePath.c_str());
|
log("[Warnning] UserDefault::init open storage file '%s' failed!", _filePath.c_str());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -9,26 +9,6 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#define O_READ_FLAGS O_BINARY | O_RDONLY, S_IREAD
|
|
||||||
#define O_WRITE_FLAGS O_CREAT | O_RDWR | O_BINARY | O_TRUNC, S_IWRITE | S_IREAD
|
|
||||||
#define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR | O_BINARY, S_IWRITE | S_IREAD
|
|
||||||
#define posix_open ::_open
|
|
||||||
#define posix_close ::_close
|
|
||||||
#define posix_lseek ::_lseek
|
|
||||||
#define posix_read ::_read
|
|
||||||
#define posix_write ::_write
|
|
||||||
#else
|
|
||||||
#define O_READ_FLAGS O_RDONLY, S_IRUSR
|
|
||||||
#define O_WRITE_FLAGS O_CREAT | O_RDWR | O_TRUNC, S_IRWXU
|
|
||||||
#define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR, S_IRWXU
|
|
||||||
#define posix_open ::open
|
|
||||||
#define posix_close ::close
|
|
||||||
#define posix_lseek ::lseek
|
|
||||||
#define posix_read ::read
|
|
||||||
#define posix_write ::write
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
struct PXIoF {
|
struct PXIoF {
|
||||||
|
|
|
@ -24,6 +24,36 @@
|
||||||
#include "base/ZipUtils.h"
|
#include "base/ZipUtils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define O_READ_FLAGS O_BINARY | O_RDONLY, S_IREAD
|
||||||
|
#define O_WRITE_FLAGS O_CREAT | O_RDWR | O_BINARY | O_TRUNC, S_IWRITE | S_IREAD
|
||||||
|
#define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR | O_BINARY, S_IWRITE | S_IREAD
|
||||||
|
|
||||||
|
#define O_OVERLAP_FLAGS O_CREAT | O_RDWR | O_BINARY, S_IWRITE | S_IREAD
|
||||||
|
|
||||||
|
#define posix_open ::_open
|
||||||
|
#define posix_close ::_close
|
||||||
|
#define posix_lseek ::_lseek
|
||||||
|
#define posix_read ::_read
|
||||||
|
#define posix_write ::_write
|
||||||
|
#define posix_fd2fh(fd) reinterpret_cast<HANDLE>(_get_osfhandle(fd))
|
||||||
|
#define posix_fsetsize(fd, size) ::_chsize(fd, size)
|
||||||
|
#else
|
||||||
|
#define O_READ_FLAGS O_RDONLY, S_IRUSR
|
||||||
|
#define O_WRITE_FLAGS O_CREAT | O_RDWR | O_TRUNC, S_IRWXU
|
||||||
|
#define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR, S_IRWXU
|
||||||
|
|
||||||
|
#define O_OVERLAP_FLAGS O_CREAT | O_RDWR, S_IRWXU
|
||||||
|
|
||||||
|
#define posix_open ::open
|
||||||
|
#define posix_close ::close
|
||||||
|
#define posix_lseek ::lseek
|
||||||
|
#define posix_read ::read
|
||||||
|
#define posix_write ::write
|
||||||
|
#define posix_fd2fh(fd) (fd)
|
||||||
|
#define posix_fsetsize(fd, size) ::ftruncate(fd, size), ::lseek(fd, 0, SEEK_SET)
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
struct UnzFileStream;
|
struct UnzFileStream;
|
||||||
|
|
Loading…
Reference in New Issue