[GRASS-dev] Re: [GRASS GIS] #1006: r.terraflow fails to stat() stream file on Windows

GRASS GIS trac at osgeo.org
Mon Jul 12 13:35:30 EDT 2010


#1006: r.terraflow fails to stat() stream file on Windows
-----------------------------------+----------------------------------------
 Reporter:  marisn                 |       Owner:  grass-dev@…              
     Type:  defect                 |      Status:  new                      
 Priority:  critical               |   Milestone:  6.4.0                    
Component:  Raster                 |     Version:  svn-releasebranch64      
 Keywords:  wingrass, r.terraflow  |    Platform:  MSWindows Vista          
      Cpu:  x86-32                 |  
-----------------------------------+----------------------------------------

Comment(by glynn):

 Replying to [comment:52 mmetz]:

 > stream_len itself is called very often

 In which case, it shouldn't be calling stat() either. This isn't exactly
 fast on Unix, is quite slow on Windows, and is extremely slow on Cygwin.

 On Unix, fstat() is typically significantly faster than stat(), as stat()
 needs to resolve the pathname to an inode, which requires lookups and
 permission checks on each component in the path.

 However: both fstat() and stat() reflect the size of the underlying file,
 which isn't necessarily the same as the size of the stream (FILE*) if
 buffering is in use. The only reliable way to determine the size of a
 stream is fseek(SEEK_END)+ftell().

 If stream_len() is called often, it would be better to make the AMI_STREAM
 class keep track of its own length, updating it in the write_item() and
 write_array() methods.

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1006#comment:53>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list