}
[Test]
- [ExpectedException(typeof(NotSupportedException))]
+ [ExpectedException(typeof(IOException))]
public void CreateViewStreamWithOffsetPastFileEnd2 ()
{
string f = Path.Combine (tempDir, "8192-file");
MemoryMappedFile mappedFile = MemoryMappedFile.CreateFromFile (f, FileMode.Open);
MemoryMappedViewStream stream = mappedFile.CreateViewStream (8191, 8191, MemoryMappedFileAccess.ReadWrite);
-
- /* Should throw exception due to trying to overflow capacity */
- stream.Write (new byte [8191], 0, 8191);
}
}
}
struct stat buf = { 0 };
fstat (fh->fd, &buf); //FIXME error handling
- if (offset > buf.st_size)
+ if (offset > buf.st_size || ((eff_size + offset) > buf.st_size && !is_special_zero_size_file (&buf)))
goto error;
/**
* We use the file size if one of the following conditions is true:
* -input size is zero
* -input size is bigger than the file and the file is not a magical zero size file such as /dev/mem.
*/
- if (eff_size == 0 || ((eff_size + offset) > buf.st_size && !is_special_zero_size_file (&buf)))
+ if (eff_size == 0)
eff_size = buf.st_size - offset;
*size = eff_size;