mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 10:02:30 +00:00
feat(system/file): implemented posix file functions SetPos() and Delete()
This commit is contained in:
parent
fba6fa66f0
commit
32f791ac70
1 changed files with 26 additions and 0 deletions
|
|
@ -598,6 +598,32 @@ bool SetAttributes(FileParms* parms) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SetPos(FileParms* parms) {
|
||||||
|
auto pos = parms->position;
|
||||||
|
auto whence = parms->whence;
|
||||||
|
auto file = parms->stream;
|
||||||
|
|
||||||
|
auto result = ::lseek(file->filefd, static_cast<off_t>(pos), whence);
|
||||||
|
|
||||||
|
if (result == -1) {
|
||||||
|
if (errno == ENOSPC) {
|
||||||
|
BC_FILE_SET_ERROR(BC_FILE_ERROR_NO_SPACE_ON_DEVICE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BC_FILE_SET_ERROR(BC_FILE_ERROR_INVALID_ARGUMENT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Delete(FileParms* parms) {
|
||||||
|
File::Path::QuickNative path(parms->filename);
|
||||||
|
|
||||||
|
return ::unlink(path.Str()) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Stacked
|
} // namespace Stacked
|
||||||
} // namespace System_File
|
} // namespace System_File
|
||||||
} // namespace Blizzard
|
} // namespace Blizzard
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue