FileStream.Linux.cs 1.3 KB

123456789101112131415161718192021222324252627282930
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using Microsoft.Win32.SafeHandles;
  5. using System.Diagnostics;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace System.IO
  9. {
  10. public partial class FileStream : Stream
  11. {
  12. /// <summary>Prevents other processes from reading from or writing to the FileStream.</summary>
  13. /// <param name="position">The beginning of the range to lock.</param>
  14. /// <param name="length">The range to be locked.</param>
  15. private void LockInternal(long position, long length)
  16. {
  17. CheckFileCall(Interop.Sys.LockFileRegion(_fileHandle, position, length, Interop.Sys.LockType.F_WRLCK));
  18. }
  19. /// <summary>Allows access by other processes to all or part of a file that was previously locked.</summary>
  20. /// <param name="position">The beginning of the range to unlock.</param>
  21. /// <param name="length">The range to be unlocked.</param>
  22. private void UnlockInternal(long position, long length)
  23. {
  24. CheckFileCall(Interop.Sys.LockFileRegion(_fileHandle, position, length, Interop.Sys.LockType.F_UNLCK));
  25. }
  26. }
  27. }