Tk Library Source Code

Artifact [5600cf5202]
Login

Artifact 5600cf52020cf59a960fa65861037044bf864b83:

Attachment "fileutil.patch" to ticket [556504ffff] added by cleverly 2002-05-16 03:51:33.
*** modules/fileutil/fileutil.tcl	Mon Jan 21 10:55:23 2002
--- modules/fileutil/fileutil-modified.tcl	Wed May 15 15:16:15 2002
***************
*** 284,290 ****
      set fd [open $filename r]
      # Use the [file size] command to get the size, which preallocates memory,
      # rather than trying to grow it as the read progresses.
!     set data [read $fd [file size $filename]]
      close $fd
      return $data
  }
--- 284,298 ----
      set fd [open $filename r]
      # Use the [file size] command to get the size, which preallocates memory,
      # rather than trying to grow it as the read progresses.
!     set size [file size $filename]
!     if {$size} {
!         set data [read $fd $size]
!     } else {
!         # if the file has zero bytes it is either empty, or something 
!         # where [file size] reports 0 but the file actually has data (like
!         # the files in the /proc filesystem on Linux)
!         set data [read $fd]
!     }
      close $fd
      return $data
  }