summaryrefslogtreecommitdiffstats
path: root/drivers/windows/file_access_windows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/windows/file_access_windows.cpp')
-rw-r--r--drivers/windows/file_access_windows.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index dd8bceb573..726e0fdc5a 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -41,6 +41,7 @@
#include <windows.h>
#include <errno.h>
+#include <io.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <tchar.h>
@@ -369,6 +370,24 @@ Error FileAccessWindows::get_error() const {
return last_error;
}
+Error FileAccessWindows::resize(int64_t p_length) {
+ ERR_FAIL_NULL_V_MSG(f, FAILED, "File must be opened before use.");
+ errno_t res = _chsize_s(_fileno(f), p_length);
+ switch (res) {
+ case 0:
+ return OK;
+ case EACCES:
+ case EBADF:
+ return ERR_FILE_CANT_OPEN;
+ case ENOSPC:
+ return ERR_OUT_OF_MEMORY;
+ case EINVAL:
+ return ERR_INVALID_PARAMETER;
+ default:
+ return FAILED;
+ }
+}
+
void FileAccessWindows::flush() {
ERR_FAIL_NULL(f);