diff options
Diffstat (limited to 'drivers/windows')
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 2 | ||||
-rw-r--r-- | drivers/windows/file_access_windows.cpp | 33 | ||||
-rw-r--r-- | drivers/windows/file_access_windows.h | 1 | ||||
-rw-r--r-- | drivers/windows/semaphore_windows.cpp | 3 |
4 files changed, 37 insertions, 2 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 2f705ec87d..9eac15f774 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -394,7 +394,7 @@ DirAccessWindows::DirAccessWindows() { if (mask & (1 << i)) { //DRIVE EXISTS - drives[drive_count] = 'a' + i; + drives[drive_count] = 'A' + i; drive_count++; } } diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index babb393dcb..c4c5e0d709 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -197,12 +197,14 @@ void FileAccessWindows::seek(size_t p_position) { last_error = OK; if (fseek(f, p_position, SEEK_SET)) check_errors(); + prev_op = 0; } void FileAccessWindows::seek_end(int64_t p_position) { ERR_FAIL_COND(!f); if (fseek(f, p_position, SEEK_END)) check_errors(); + prev_op = 0; } size_t FileAccessWindows::get_position() const { @@ -234,6 +236,12 @@ bool FileAccessWindows::eof_reached() const { uint8_t FileAccessWindows::get_8() const { ERR_FAIL_COND_V(!f, 0); + if (flags == READ_WRITE || flags == WRITE_READ) { + if (prev_op == WRITE) { + fflush(f); + } + prev_op = READ; + } uint8_t b; if (fread(&b, 1, 1, f) == 0) { check_errors(); @@ -246,6 +254,12 @@ uint8_t FileAccessWindows::get_8() const { int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const { ERR_FAIL_COND_V(!f, -1); + if (flags == READ_WRITE || flags == WRITE_READ) { + if (prev_op == WRITE) { + fflush(f); + } + prev_op = READ; + } int read = fread(p_dst, 1, p_length, f); check_errors(); return read; @@ -260,16 +274,34 @@ void FileAccessWindows::flush() { ERR_FAIL_COND(!f); fflush(f); + if (prev_op == WRITE) + prev_op = 0; } void FileAccessWindows::store_8(uint8_t p_dest) { ERR_FAIL_COND(!f); + if (flags == READ_WRITE || flags == WRITE_READ) { + if (prev_op == READ) { + if (last_error != ERR_FILE_EOF) { + fseek(f, 0, SEEK_CUR); + } + } + prev_op = WRITE; + } fwrite(&p_dest, 1, 1, f); } void FileAccessWindows::store_buffer(const uint8_t *p_src, int p_length) { ERR_FAIL_COND(!f); + if (flags == READ_WRITE || flags == WRITE_READ) { + if (prev_op == READ) { + if (last_error != ERR_FILE_EOF) { + fseek(f, 0, SEEK_CUR); + } + } + prev_op = WRITE; + } ERR_FAIL_COND(fwrite(p_src, 1, p_length, f) != p_length); } @@ -310,6 +342,7 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) { FileAccessWindows::FileAccessWindows() : f(NULL), flags(0), + prev_op(0), last_error(OK) { } FileAccessWindows::~FileAccessWindows() { diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h index c105eb5265..35b1f0b2d8 100644 --- a/drivers/windows/file_access_windows.h +++ b/drivers/windows/file_access_windows.h @@ -47,6 +47,7 @@ class FileAccessWindows : public FileAccess { FILE *f; int flags; void check_errors() const; + mutable int prev_op; mutable Error last_error; String path; String path_src; diff --git a/drivers/windows/semaphore_windows.cpp b/drivers/windows/semaphore_windows.cpp index 718bb81836..55b47e45eb 100644 --- a/drivers/windows/semaphore_windows.cpp +++ b/drivers/windows/semaphore_windows.cpp @@ -54,7 +54,8 @@ int SemaphoreWindows::get() const { case WAIT_TIMEOUT: { return 0; } break; - default: {} + default: { + } } ERR_FAIL_V(-1); |