mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-06 16:25:59 +02:00
Improve WriteTextFile safety
This commit is contained in:
parent
06fe5a98c6
commit
8a210699c7
1 changed files with 6 additions and 4 deletions
|
@ -295,11 +295,13 @@ namespace Beefy
|
||||||
|
|
||||||
public static Result<void> WriteTextFile(StringView path, StringView text)
|
public static Result<void> WriteTextFile(StringView path, StringView text)
|
||||||
{
|
{
|
||||||
var stream = scope FileStream();
|
var stream = scope UnbufferedFileStream();
|
||||||
if (stream.Create(path) case .Err)
|
if (stream.Open(path, .OpenOrCreate, .Write) case .Err)
|
||||||
{
|
|
||||||
return .Err;
|
return .Err;
|
||||||
}
|
|
||||||
|
if (stream.SetLength(text.Length) case .Err)
|
||||||
|
return .Err;
|
||||||
|
|
||||||
if (stream.WriteStrUnsized(text) case .Err)
|
if (stream.WriteStrUnsized(text) case .Err)
|
||||||
return .Err;
|
return .Err;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue