summary refs log tree commit diff stats
diff options
context:
space:
mode:
authordef <dennis@felsin9.de>2016-03-17 22:22:52 +0100
committerdef <dennis@felsin9.de>2016-03-17 22:22:52 +0100
commitd5c332ffa8b0774593c3548167f85d91388b23b1 (patch)
treeb1b3142ac71440e508bc917c66b089f04751f7f4
parent7fa3d58167579bd493a026cbea5c815935df4ea6 (diff)
downloadNim-d5c332ffa8b0774593c3548167f85d91388b23b1.tar.gz
Comment to explain not opening directories in open()
-rw-r--r--lib/system/sysio.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 512bf1f51..4ced51c96 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -289,6 +289,9 @@ proc open(f: var File, filename: string,
   var p: pointer = fopen(filename, FormatOpen[mode])
   if p != nil:
     when defined(posix) and not defined(nimscript):
+      # How `fopen` handles opening a directory is not specified in ISO C and
+      # POSIX. We do not want to handle directories as regular files that can
+      # be opened.
       var f2 = cast[File](p)
       var res: Stat
       if fstat(getFileHandle(f2), res) >= 0'i32 and S_ISDIR(res.st_mode):