mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
parent
2e266dfe3c
commit
cf904e0a5d
@ -683,7 +683,9 @@ class Genode::New_file : Noncopyable
|
||||
Vfs::File_system &_fs;
|
||||
Vfs::Vfs_handle &_handle;
|
||||
|
||||
Vfs::Vfs_handle &_init_handle(Directory &dir, Directory::Path const &rel_path)
|
||||
Vfs::Vfs_handle &_init_handle(Directory &dir,
|
||||
Directory::Path const &rel_path,
|
||||
bool append)
|
||||
{
|
||||
/* create compound directory */
|
||||
{
|
||||
@ -708,7 +710,11 @@ class Genode::New_file : Noncopyable
|
||||
throw Create_failed();
|
||||
}
|
||||
|
||||
handle_ptr->fs().ftruncate(handle_ptr, 0);
|
||||
Vfs::Directory_service::Stat stat { };
|
||||
if (!append)
|
||||
handle_ptr->fs().ftruncate(handle_ptr, 0);
|
||||
else if (handle_ptr->ds().stat(path.string(), stat) == Vfs::Directory_service::STAT_OK)
|
||||
handle_ptr->seek(stat.size);
|
||||
|
||||
return *handle_ptr;
|
||||
}
|
||||
@ -720,10 +726,10 @@ class Genode::New_file : Noncopyable
|
||||
*
|
||||
* \throw Create_failed
|
||||
*/
|
||||
New_file(Directory &dir, Directory::Path const &path)
|
||||
New_file(Directory &dir, Directory::Path const &path, bool append = false)
|
||||
:
|
||||
_ep(dir._ep), _alloc(dir._alloc), _fs(dir._fs),
|
||||
_handle(_init_handle(dir, path))
|
||||
_handle(_init_handle(dir, path, append))
|
||||
{ }
|
||||
|
||||
~New_file()
|
||||
|
Loading…
Reference in New Issue
Block a user