创建一定大小的文件,并在iOS上不填充任何数据 [英] Create a certain size file and filled with no data on iOS

查看:49
本文介绍了创建一定大小的文件,并在iOS上不填充任何数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发iphone应用程序,我需要在文件系统上创建一个特定大小的文件,并先填充NO数据,然后寻找偏移量并从其他地方获取数据时写入数据
我该怎么办?

I'm developing an iphone app, I need to create a certain size file on filesystem and filled with NO data first, then seek to a offset and write data when get data from somewhere else
How can I do it?

推荐答案

man lseek :

lseek()函数允许在文件末尾以外设置文件偏移量文件的现有文件末尾.如果稍后再写入数据,后续读取间隙中的数据将返回零字节(直到数据为实际被写入差距).

The lseek() function allows the file offset to be set beyond the end of the existing end-of-file of the file. If data is later written at this point, subsequent reads of the data in the gap return bytes of zeros (until data is actually written into the gap).

这篇关于创建一定大小的文件,并在iOS上不填充任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆