diff options
Diffstat (limited to 'drivers/unix/file_access_unix.cpp')
-rw-r--r-- | drivers/unix/file_access_unix.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index a35d8bfdde..ea8b42b2e4 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -286,6 +286,23 @@ Error FileAccessUnix::get_error() const { return last_error; } +Error FileAccessUnix::resize(int64_t p_length) { + ERR_FAIL_NULL_V_MSG(f, FAILED, "File must be opened before use."); + int res = ::ftruncate(fileno(f), p_length); + switch (res) { + case 0: + return OK; + case EBADF: + return ERR_FILE_CANT_OPEN; + case EFBIG: + return ERR_OUT_OF_MEMORY; + case EINVAL: + return ERR_INVALID_PARAMETER; + default: + return FAILED; + } +} + void FileAccessUnix::flush() { ERR_FAIL_NULL_MSG(f, "File must be opened before use."); fflush(f); @@ -366,7 +383,7 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) { if (!err) { return status.st_mtime; } else { - print_verbose("Failed to get modified time for: " + p_file + ""); + WARN_PRINT("Failed to get modified time for: " + p_file); return 0; } } |