mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Properly truncate files
This commit is contained in:
parent
546e5f7e5e
commit
9158002a42
2 changed files with 8 additions and 7 deletions
|
@ -17,16 +17,16 @@ namespace System.IO
|
||||||
/// Opens an existing file. Fails if the file does not exist.
|
/// Opens an existing file. Fails if the file does not exist.
|
||||||
Open = 3,
|
Open = 3,
|
||||||
|
|
||||||
// Opens the file if it exists. Otherwise, creates a new file.
|
/// Opens the file if it exists. Otherwise, creates a new file.
|
||||||
OpenOrCreate = 4,
|
OpenOrCreate = 4,
|
||||||
|
|
||||||
// Opens an existing file. Once opened, the file is truncated so that its
|
/// Opens an existing file. Once opened, the file is truncated so that its
|
||||||
// size is zero bytes. The calling process must open the file with at least
|
/// size is zero bytes. The calling process must open the file with at least
|
||||||
// WRITE access. Fails if the file does not exist.
|
/// WRITE access. Fails if the file does not exist.
|
||||||
Truncate = 5,
|
Truncate = 5,
|
||||||
|
|
||||||
// Opens the file if it exists and seeks to the end. Otherwise,
|
/// Opens the file if it exists and seeks to the end. Otherwise,
|
||||||
// creates a new file.
|
/// creates a new file.
|
||||||
Append = 6,
|
Append = 6,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,12 +175,13 @@ namespace System.IO
|
||||||
createKind = .CreateIfNotExists;
|
createKind = .CreateIfNotExists;
|
||||||
case .Create:
|
case .Create:
|
||||||
createKind = .CreateAlways;
|
createKind = .CreateAlways;
|
||||||
|
createFlags |= .Truncate;
|
||||||
case .Open:
|
case .Open:
|
||||||
createKind = .OpenExisting;
|
createKind = .OpenExisting;
|
||||||
case .OpenOrCreate:
|
case .OpenOrCreate:
|
||||||
createKind = .OpenAlways;
|
createKind = .OpenAlways;
|
||||||
case .Truncate:
|
case .Truncate:
|
||||||
createKind = .CreateAlways;
|
createKind = .OpenExisting;
|
||||||
createFlags |= .Truncate;
|
createFlags |= .Truncate;
|
||||||
case .Append:
|
case .Append:
|
||||||
createKind = .CreateAlways;
|
createKind = .CreateAlways;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue