@@ -81,9 +81,18 @@ use time::SystemTime;
81
81
/// # }
82
82
/// ```
83
83
///
84
+ /// Note that, although read and write methods require a `&mut File`, because
85
+ /// of the interfaces for [`Read`] and [`Write`], it is still possible to
86
+ /// modify a file through a `&File`, either through methods that take `&File`
87
+ /// or by retrieving a raw OS filehandle and modifying the file that way.
88
+ /// Additionally, many operating systems allow concurrent modification of files
89
+ /// by different processes. Care should be taken not to assume that holding a
90
+ /// `&File` means that the file will not change.
91
+ ///
84
92
/// [`Seek`]: ../io/trait.Seek.html
85
93
/// [`String`]: ../string/struct.String.html
86
94
/// [`Read`]: ../io/trait.Read.html
95
+ /// [`Write`]: ../io/trait.Write.html
87
96
/// [`BufReader<R>`]: ../io/struct.BufReader.html
88
97
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
89
98
pub struct File {
@@ -459,6 +468,9 @@ impl File {
459
468
/// # Ok(())
460
469
/// # }
461
470
/// ```
471
+ ///
472
+ /// Note that this method alters the content of the underlying file, even
473
+ /// though it takes `&self` rather than `&mut self`.
462
474
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
463
475
pub fn set_len ( & self , size : u64 ) -> io:: Result < ( ) > {
464
476
self . inner . truncate ( size)
@@ -557,6 +569,9 @@ impl File {
557
569
/// # Ok(())
558
570
/// # }
559
571
/// ```
572
+ ///
573
+ /// Note that this method alters the permissions of the underlying file,
574
+ /// even though it takes `&self` rather than `&mut self`.
560
575
#[ stable( feature = "set_permissions_atomic" , since = "1.16.0" ) ]
561
576
pub fn set_permissions ( & self , perm : Permissions ) -> io:: Result < ( ) > {
562
577
self . inner . set_permissions ( perm. 0 )
0 commit comments