Skip to content

Commit 6dc7819

Browse files
authored
Fixed exception that prevented creating a memory mapped file that sha… (#8747)
* Fixed exception that prevented creating a memory mapped file that shadow copies a file on-disk (#8238) * Fixed exception that prevented creating a memory mapped file that is shadow copied * Update bytes.fs * Added test for old fsharp core project
1 parent 4567bf9 commit 6dc7819

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/absil/bytes.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,11 @@ type ByteMemory with
306306
leaveOpen=false)
307307
mmf, mmf.CreateViewAccessor(0L, length, memoryMappedFileAccess), length
308308

309+
// Validate MMF with the access that was intended.
309310
match access with
310-
| FileAccess.Read when not accessor.CanRead -> failwith "Cannot read file"
311-
| FileAccess.Write when not accessor.CanWrite -> failwith "Cannot write file"
312-
| _ when not accessor.CanRead || not accessor.CanWrite -> failwith "Cannot read or write file"
311+
| FileAccess.Read when not accessor.CanRead -> invalidOp "Cannot read file"
312+
| FileAccess.Write when not accessor.CanWrite -> invalidOp "Cannot write file"
313+
| FileAccess.ReadWrite when not accessor.CanRead || not accessor.CanWrite -> invalidOp "Cannot read or write file"
313314
| _ -> ()
314315

315316
let safeHolder =
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Learn more about F# at http://fsharp.org
2+
3+
open System
4+
5+
6+
[<EntryPoint>]
7+
let main argv =
8+
printfn "Hello World from F#!"
9+
0 // return an integer exit code
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net35</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="Program.fs" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Update="FSharp.Core" Version="3.0.2" />
14+
</ItemGroup>
15+
16+
</Project>

0 commit comments

Comments
 (0)