private void UnlockFile(long offset, long count) { #if !SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME && !SILICONSTUDIO_PLATFORM_MONO_MOBILE var fileStream = stream as FileStream; if (fileStream == null) { return; } #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP var countLow = (uint)count; var countHigh = (uint)(count >> 32); var overlapped = new NativeLockFile.OVERLAPPED() { internalLow = 0, internalHigh = 0, offsetLow = (uint)offset, offsetHigh = (uint)(offset >> 32), hEvent = IntPtr.Zero, }; if (!NativeLockFile.UnlockFileEx(fileStream.SafeFileHandle, 0, countLow, countHigh, ref overlapped)) { throw new IOException("Couldn't unlock file."); } #else fileStream.Unlock(offset, count); #endif #endif }
private void UnlockFile(long offset, long count) { #if !SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME var fileStream = stream as FileStream; if (fileStream == null) { return; } #if SILICONSTUDIO_PLATFORM_ANDROID // See comment on `LockFile`. count = (count + offset > int.MaxValue) ? int.MaxValue - offset: count; #endif #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP var countLow = (uint)count; var countHigh = (uint)(count >> 32); var overlapped = new NativeLockFile.OVERLAPPED() { internalLow = 0, internalHigh = 0, offsetLow = (uint)offset, offsetHigh = (uint)(offset >> 32), hEvent = IntPtr.Zero, }; if (!NativeLockFile.UnlockFileEx(fileStream.SafeFileHandle, 0, countLow, countHigh, ref overlapped)) { throw new IOException("Couldn't unlock file."); } #elif SILICONSTUDIO_RUNTIME_CORECLR // There is no implementation of FileStream.Unlock on CoreCLR #else fileStream.Unlock(offset, count); #endif #endif }