C Low-Level I/O functions

以前在看别人的很多代码时候,经常看到低级的C语言文件I/O函数。不过自己却从来还没有用到过低级的I/O函数。在纯C里面就f开头的stream用得多。这次要做SIDB在底层实现数据库存储文件,就得必须依靠低级文件I/O才能做了。因为低级文件I/O提供了某些功能,而高级文件I/O函数中没有。

  这是我在网上找到为什么要使用低级IO的一些原因:

摘自: http://www.linuxtopia.org/online_books/programming_books/gnu_libc_guide/Low_002dLevel-I_002fO.html

  • For reading binary files in large chunks.
  • For reading an entire file into core before parsing it.
  • To perform operations other than data transfer, which can only be done with a descriptor. (You can use fileno to get the descriptor corresponding to a stream.)
  • To pass descriptors to a child process. (The child can create its own stream to use a descriptor that it inherits, but cannot inherit a stream directly.)

 

下面是我总结一些文件必须使用Low-Level的I/O函数的原因:

1. 低级IO没有提供buffer,而我们使用f开头以及C++等很多文件操作,都是带缓冲的。
2. 低级IO在功能上更加强大。据我所知,诸如_filelength和_chsize,获取文件的长度和改变文件的长度,这两个函数,在高级文件IO中是找不到的。

关于Low-Level的文件I/O资料,可以在下面网址找到:
http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_8.html
http://www.gnu.org/software/libc/manual/html_node/Low_002dLevel-I_002fO.html
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=208
http://www.thinkage.ca/english/gcos/expl/c/lib/open.html

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值