mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +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)
|
||||
{
|
||||
var stream = scope FileStream();
|
||||
if (stream.Create(path) case .Err)
|
||||
{
|
||||
var stream = scope UnbufferedFileStream();
|
||||
if (stream.Open(path, .OpenOrCreate, .Write) case .Err)
|
||||
return .Err;
|
||||
}
|
||||
|
||||
if (stream.SetLength(text.Length) case .Err)
|
||||
return .Err;
|
||||
|
||||
if (stream.WriteStrUnsized(text) case .Err)
|
||||
return .Err;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue