Skip to content

Commit 8fdd993

Browse files
committed
Document that locking a file fails on Windows if the file is opened only for append
1 parent 271a3d1 commit 8fdd993

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

library/std/src/fs.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,9 @@ impl File {
648648
/// and the `LockFileEx` function on Windows with the `LOCKFILE_EXCLUSIVE_LOCK` flag. Note that,
649649
/// this [may change in the future][changes].
650650
///
651+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
652+
/// open it with either `.read(true).append(true)` or `.write(true)`.
653+
///
651654
/// [changes]: io#platform-specific-behavior
652655
///
653656
/// [`lock_shared`]: File::lock_shared
@@ -697,6 +700,9 @@ impl File {
697700
/// and the `LockFileEx` function on Windows. Note that, this
698701
/// [may change in the future][changes].
699702
///
703+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
704+
/// open it with either `.read(true).append(true)` or `.write(true)`.
705+
///
700706
/// [changes]: io#platform-specific-behavior
701707
///
702708
/// [`lock`]: File::lock
@@ -751,6 +757,9 @@ impl File {
751757
/// and `LOCKFILE_FAIL_IMMEDIATELY` flags. Note that, this
752758
/// [may change in the future][changes].
753759
///
760+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
761+
/// open it with either `.read(true).append(true)` or `.write(true)`.
762+
///
754763
/// [changes]: io#platform-specific-behavior
755764
///
756765
/// [`lock`]: File::lock
@@ -804,6 +813,9 @@ impl File {
804813
/// `LOCKFILE_FAIL_IMMEDIATELY` flag. Note that, this
805814
/// [may change in the future][changes].
806815
///
816+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
817+
/// open it with either `.read(true).append(true)` or `.write(true)`.
818+
///
807819
/// [changes]: io#platform-specific-behavior
808820
///
809821
/// [`lock`]: File::lock
@@ -845,6 +857,9 @@ impl File {
845857
/// and the `UnlockFile` function on Windows. Note that, this
846858
/// [may change in the future][changes].
847859
///
860+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
861+
/// open it with either `.read(true).append(true)` or `.write(true)`.
862+
///
848863
/// [changes]: io#platform-specific-behavior
849864
///
850865
/// # Examples

0 commit comments

Comments
 (0)