about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-12-05 00:22:58 +0000
committerbors <bors@rust-lang.org>2014-12-05 00:22:58 +0000
commit361baabb07b2fb921d0f556d0787b3ea7ef86746 (patch)
treebc61837ee47ed0611090b199b69e43a89e5c5c7b /src/libstd/sys
parentd9c7c00b9a3d80fc81fbbb77a9f21e5f71a1d213 (diff)
parent3980cdecd073789fb5ff7256e2ca40685a289b01 (diff)
downloadrust-361baabb07b2fb921d0f556d0787b3ea7ef86746.tar.gz
rust-361baabb07b2fb921d0f556d0787b3ea7ef86746.zip
auto merge of #19303 : nodakai/rust/libsyntax-reject-dirs, r=alexcrichton
On *BSD systems, we can `open(2)` a directory and directly `read(2)` from it due to an old tradition.  We should avoid doing so by explicitly calling `fstat(2)` to check the type of the opened file.

Opening a directory as a module file can't always be avoided.  Even when there's no "path" attribute trick involved, there can always be a *directory* named `my_module.rs`.

Incidentally, remove unnecessary mutability of `&self` from `io::fs::File::stat()`.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/windows/fs.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs
index 9c4ffb926b5..9402c63dcf5 100644
--- a/src/libstd/sys/windows/fs.rs
+++ b/src/libstd/sys/windows/fs.rs
@@ -131,7 +131,7 @@ impl FileDesc {
         return ret;
     }
 
-    pub fn fstat(&mut self) -> IoResult<io::FileStat> {
+    pub fn fstat(&self) -> IoResult<io::FileStat> {
         let mut stat: libc::stat = unsafe { mem::zeroed() };
         match unsafe { libc::fstat(self.fd(), &mut stat) } {
             0 => Ok(mkstat(&stat)),