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/detail/sz.hpp"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#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
|
||||
#include "CCFileStream.h"
|
||||
|
||||
#define USER_DEFAULT_PLAIN_MODE 0
|
||||
|
||||
|
@ -168,7 +146,7 @@ bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue)
|
|||
{
|
||||
auto it = this->_values.find(pKey);
|
||||
if (it != this->_values.end())
|
||||
return it->second == "1";
|
||||
return it->second == "true";
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -381,7 +359,7 @@ void UserDefault::init()
|
|||
|
||||
#if !USER_DEFAULT_PLAIN_MODE
|
||||
// construct file mapping
|
||||
_fd = posix_open(_filePath.c_str(), O_WRITE_FLAGS);
|
||||
_fd = posix_open(_filePath.c_str(), O_OVERLAP_FLAGS);
|
||||
if (_fd == -1) {
|
||||
log("[Warnning] UserDefault::init open storage file '%s' failed!", _filePath.c_str());
|
||||
return;
|
||||
|
|
|
@ -9,26 +9,6 @@
|
|||
#include <sys/stat.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
|
||||
|
||||
struct PXIoF {
|
||||
|
|
|
@ -24,6 +24,36 @@
|
|||
#include "base/ZipUtils.h"
|
||||
#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
|
||||
|
||||
struct UnzFileStream;
|
||||
|
|
Loading…
Reference in New Issue