Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateFromFile() [1/6]

static MemoryMappedFile System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile ( FileStream fileStream,
string? mapName,
long capacity,
MemoryMappedFileAccess access,
HandleInheritability inheritability,
bool leaveOpen )
inlinestatic

Definition at line 142 of file MemoryMappedFile.cs.

143 {
144 if (fileStream == null)
145 {
146 throw new ArgumentNullException("fileStream", System.SR.ArgumentNull_FileStream);
147 }
148 if (mapName != null && mapName.Length == 0)
149 {
151 }
152 if (capacity < 0)
153 {
154 throw new ArgumentOutOfRangeException("capacity", System.SR.ArgumentOutOfRange_PositiveOrDefaultCapacityRequired);
155 }
156 if (capacity == 0L && fileStream.Length == 0L)
157 {
159 }
160 switch (access)
161 {
162 default:
163 throw new ArgumentOutOfRangeException("access");
164 case MemoryMappedFileAccess.Write:
166 case MemoryMappedFileAccess.ReadWrite:
167 case MemoryMappedFileAccess.Read:
168 case MemoryMappedFileAccess.CopyOnWrite:
169 case MemoryMappedFileAccess.ReadExecute:
170 case MemoryMappedFileAccess.ReadWriteExecute:
171 {
172 if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable)
173 {
174 throw new ArgumentOutOfRangeException("inheritability");
175 }
176 fileStream.Flush();
177 if (capacity == 0L)
178 {
179 capacity = fileStream.Length;
180 }
181 SafeMemoryMappedFileHandle handle = CreateCore(fileStream, mapName, inheritability, access, MemoryMappedFileOptions.None, capacity);
182 return new MemoryMappedFile(handle, fileStream, leaveOpen);
183 }
184 }
185 }
MemoryMappedFile(SafeMemoryMappedFileHandle handle)
static SafeMemoryMappedFileHandle CreateCore(FileStream fileStream, string mapName, HandleInheritability inheritability, MemoryMappedFileAccess access, MemoryMappedFileOptions options, long capacity)
static string Argument_NewMMFWriteAccessNotAllowed
Definition SR.cs:42
static string ArgumentNull_FileStream
Definition SR.cs:52
static string Argument_MapNameEmptyString
Definition SR.cs:38
static string ArgumentOutOfRange_PositiveOrDefaultCapacityRequired
Definition SR.cs:58
static string Argument_EmptyFile
Definition SR.cs:40
Definition SR.cs:7

References System.IO.MemoryMappedFiles.MemoryMappedFile.MemoryMappedFile(), System.SR.Argument_EmptyFile, System.SR.Argument_MapNameEmptyString, System.SR.Argument_NewMMFWriteAccessNotAllowed, System.SR.ArgumentNull_FileStream, System.SR.ArgumentOutOfRange_PositiveOrDefaultCapacityRequired, System.capacity, System.IO.MemoryMappedFiles.MemoryMappedFile.CreateCore(), System.IO.FileStream.Flush(), System.handle, System.L, and System.IO.FileStream.Length.