mirror of
https://github.com/SabreTools/SabreTools.IO.git
synced 2026-09-23 07:05:38 +00:00
Sanity checks before writing
This commit is contained in:
@@ -410,6 +410,10 @@ namespace SabreTools.IO.Extensions
|
||||
/// </summary>
|
||||
private static bool WriteFromBuffer(BinaryWriter writer, byte[] value)
|
||||
{
|
||||
// If the stream is not writable
|
||||
if (!writer.BaseStream.CanWrite)
|
||||
return false;
|
||||
|
||||
// Handle the 0-byte case
|
||||
if (value.Length == 0)
|
||||
return true;
|
||||
|
||||
@@ -408,6 +408,10 @@ namespace SabreTools.IO.Extensions
|
||||
/// </summary>
|
||||
private static bool WriteFromBuffer(Stream stream, byte[] value)
|
||||
{
|
||||
// If the stream is not writable
|
||||
if (!stream.CanWrite)
|
||||
return false;
|
||||
|
||||
// Handle the 0-byte case
|
||||
if (value.Length == 0)
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user