mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 01:51:10 +00:00
[FileAccess] Implement resize method.
This commit is contained in:
parent
029aadef56
commit
88b3e68f93
19 changed files with 111 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue