douping7975 2015-06-29 22:55
浏览 33
已采纳

为什么包括调用stream_flush?

I have written a stream wrapper and when I call include foo://bar my stream_flush implementation gets called. stream_open gets called with rb. So... why is flush called? Since the file is opened read only I do not really have anything to do there if my understanding of stream_flush is correct but then again if my understanding would be correct it wouldn't be called in the first place.

Edit: since this got an "unclear what you are asking" close vote: the question really is, what should I do in my stream_flush implementation when it is called on a read only fie?

  • 写回答

1条回答 默认 最新

  • douchi0028 2015-06-30 02:00
    关注

    stream_flush was generally called when a stream is being closed. I don't really see any reason why it's done always. It makes sense when something was written, but not really when nothing was written at all (aka reading only).

    In code is noted /* make sure everything is saved */, which is totally fine if anything has been written.

    Fixed via http://git.php.net/?p=php-src.git;a=commitdiff;h=6ad9cd5367734276d624d6d2a03406ed0d0cd08b (PHP 7.0 tree) ... stream_flush now only ever is called when either explicitly flushed or upon close while something was written, but not yet flushed. Also clarified in docs http://svn.php.net/viewvc/phpdoc/en/trunk/reference/stream/streamwrapper/stream-flush.xml?r1=337084&r2=337083&pathrev=337084 (may take until Friday that all docs are rebuilt).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习残差模块模型
  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)