如何在C中快速创建大文件? [英] How to quickly create large files in C?

查看:123
本文介绍了如何在C中快速创建大文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究文件系统的性能,并且对如何在C中快速创建非常大的文件感到困惑.基本上,我试图通过获取此元数据并存储来重新创建文件系统的文件夹和文件.它成一个文件.这是提取过程.稍后,我想使用以前提取的元数据将这些文件夹和文件还原到现有的新文件系统(在本例中为ext3)中.

I am doing research on file system performance, and I am stumped on how to create a very large file very quickly in C. Basically, I am trying to re-create a file system's folders and files by taking this metadata and storing it into a file. This is the extraction process. Later, I want to restore those folders and files into an existing freshly-made file system (in this case, ext3) using the metadata I previously extracted.

在还原过程中,我已经成功创建了所有文件夹.但是,我对如何立即创建文件有些困惑.对于我要创建的每个文件,我都有一个文件大小和一个文件路径.我只是对如何快速设置文件大小感到困惑.

In the restore process, I have already succeeded in creating all the folders. However, I am a little confused on how to create the files instantly. For every file that I want to create, I have a file size and a file path. I am just confused on how to set the size of the file very quickly.

我使用了 truncate ,但这似乎并不会影响磁盘空间的使用文件系统的角度.

I used truncate, but this does not seem to affect the disk space usage from the point of view of the file system.

谢谢!

推荐答案

无法立即执行.

您需要将文件的每个块都写在磁盘上,这将花费大量时间,尤其是对于大文件.

You need to have each block of the file written on disk and this is going to take a significant period of time, especially for a large file.

这篇关于如何在C中快速创建大文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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