[Kernel] Allow renaming and unlinking open guest files
Co-authored-by: Sekai <140012992+SekaixX@users.noreply.github.com>
This commit is contained in:
parent
c37f76f12d
commit
f945215935
|
|
@ -274,7 +274,7 @@ public static partial class KernelMemoryCompatExports
|
|||
|
||||
try
|
||||
{
|
||||
using var stream = new FileStream(hostPath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
|
||||
using var stream = new FileStream(hostPath, FileMode.Open, FileAccess.Write, GuestFileShare);
|
||||
stream.SetLength(length);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace SharpEmu.Libs.Kernel;
|
|||
public static partial class KernelMemoryCompatExports
|
||||
{
|
||||
private const int MaxGuestStringLength = 4096;
|
||||
internal const FileShare GuestFileShare = FileShare.ReadWrite | FileShare.Delete;
|
||||
private const int WideCharSize = sizeof(ushort);
|
||||
private const int MemsetChunkSize = 16 * 1024;
|
||||
private static readonly byte[] _zeroChunk = new byte[MemsetChunkSize];
|
||||
|
|
@ -1519,7 +1520,7 @@ public static partial class KernelMemoryCompatExports
|
|||
}
|
||||
|
||||
EnsureOpenParentDirectoryExists(guestPath, hostPath, flags);
|
||||
var stream = new FileStream(hostPath, mode, access, FileShare.ReadWrite);
|
||||
var stream = new FileStream(hostPath, mode, access, GuestFileShare);
|
||||
if ((flags & O_APPEND) != 0)
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.End);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ public static class LibcStdioExports
|
|||
}
|
||||
}
|
||||
|
||||
var stream = new FileStream(hostPath, fileMode, fileAccess, FileShare.ReadWrite);
|
||||
var stream = new FileStream(hostPath, fileMode, fileAccess, KernelMemoryCompatExports.GuestFileShare);
|
||||
if (mode.StartsWith('a') && fileAccess == FileAccess.ReadWrite)
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.End);
|
||||
|
|
@ -1063,7 +1063,7 @@ public static class LibcStdioExports
|
|||
}
|
||||
}
|
||||
|
||||
var replacement = new FileStream(hostPath, fileMode, fileAccess, FileShare.ReadWrite);
|
||||
var replacement = new FileStream(hostPath, fileMode, fileAccess, KernelMemoryCompatExports.GuestFileShare);
|
||||
lock (file.Gate)
|
||||
{
|
||||
if (file.IsClosed)
|
||||
|
|
|
|||
Loading…
Reference in New Issue