You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
[FileAccess] Implement resize method.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user