mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:07:35 +00:00
Userland: Open files for save in write-only mode
WavWriter and the shot utility open files with this mode and never truncate the files, which might leave some contents of a previous file during overwriting.
This commit is contained in:
parent
fb305b66c2
commit
55b6e07a0f
2 changed files with 2 additions and 2 deletions
|
@ -33,7 +33,7 @@ WavWriter::~WavWriter()
|
||||||
|
|
||||||
ErrorOr<void> WavWriter::set_file(StringView path)
|
ErrorOr<void> WavWriter::set_file(StringView path)
|
||||||
{
|
{
|
||||||
m_file = TRY(Core::File::open(path, Core::File::OpenMode::ReadWrite));
|
m_file = TRY(Core::File::open(path, Core::File::OpenMode::Write));
|
||||||
TRY(m_file->seek(44, SeekMode::SetPosition));
|
TRY(m_file->seek(44, SeekMode::SetPosition));
|
||||||
m_finalized = false;
|
m_finalized = false;
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -160,7 +160,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
if (edit_image)
|
if (edit_image)
|
||||||
output_path = Core::DateTime::now().to_deprecated_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
|
output_path = Core::DateTime::now().to_deprecated_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
|
||||||
|
|
||||||
auto file_or_error = Core::File::open(output_path, Core::File::OpenMode::ReadWrite);
|
auto file_or_error = Core::File::open(output_path, Core::File::OpenMode::Write);
|
||||||
if (file_or_error.is_error()) {
|
if (file_or_error.is_error()) {
|
||||||
warnln("Could not open '{}' for writing: {}", output_path, file_or_error.error());
|
warnln("Could not open '{}' for writing: {}", output_path, file_or_error.error());
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue