【求助】大文件的操作,类似于winhex 那样的

shakaqrj 2016-06-12 03:58:51
加精
需要编写类似于winhex那样的程序,用于显示和修改其中的数据。
比如首先创建8G字节文件,之后再通过载入其他文件或者手动修改的方式 改变其中的数据。
一般来说这8G中大部分数据都是无用的,可能是0x0 或0xFF 或其他一些值。所载入的文件有可能很大(比如6G) 也有可能很小(相对于8G),手动的修改也有可能发生

最后可能还需要保存这8G文件。

那么我该如何做才能做才能使速度变快?如果是创建初始值为0x0的,用内存映射方式直接创建一个就行了 很快。但如果创建初始值是其他的 就不知道方法了。
并且保存的时候有没有方法?
我看类似的软件 初始值不为0x0的也非常快,保存下来的文件也很小 如果内容本身就几乎是空数据(0x0,0xFF或者其他的),怀疑是用压缩算法的,可问题是我自己用压缩工具压缩也没这么小。

...全文
1816 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_35611513 2016-07-15
  • 打赏
  • 举报
回复
顶~~~~~~~~~~~~~`
sinat_35613199 2016-07-15
  • 打赏
  • 举报
回复
不懂,等大神
sinat_35613199 2016-07-15
  • 打赏
  • 举报
回复
不懂,等大神
A305106117 2016-07-14
  • 打赏
  • 举报
回复
搞什么,下个东西也下不了
qq_35604665 2016-07-14
  • 打赏
  • 举报
回复
很好,很不错
gz_qmc 2016-07-14
  • 打赏
  • 举报
回复
CreateFile(fName, GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); 看红色,看红色,看红色
gz_qmc 2016-07-14
  • 打赏
  • 举报
回复
创建模式!!!!!!!!!!!!!!!!! 无则创建,有则打开,这就是你说的初始值吧?
qq_35601330 2016-07-14
  • 打赏
  • 举报
回复
liLongZHEN123 2016-07-13
  • 打赏
  • 举报
回复
看不懂,什么
zkmcsdn 2016-07-12
  • 打赏
  • 举报
回复
好高大上的样子
baidu_35580160 2016-07-12
  • 打赏
  • 举报
回复
计价规范尽快快快快
jm0527 2016-07-12
  • 打赏
  • 举报
回复
不懂,等大神
qq_35585262 2016-07-12
  • 打赏
  • 举报
回复
规划法规和 jkj123
失散糖 2016-07-11
  • 打赏
  • 举报
回复
这个帖子的方法,把建立文件需要的磁盘空间申请好,但是省去了系统“好心帮忙”对占用空间的擦除操作,这就省去了大量的擦除时间,代价就是文件内容全是“乱码”,得到的好处就是文件可以立即拿来操作。(创建时需要管理员权限) 根据我的测试,Sparse File Operations啦,内存映射文件啦,这些看起来好像是把文件创建完了也都清零了,但是一旦使用fopen系列函数对文件进行操作,那么这种文件会转换成普通文件,然后会耗费大量的时间用于申请并擦除扇区,之后才能变成普通文件。 bbs.csdn.net/topics/391006799
lovep0515 2016-07-11
  • 打赏
  • 举报
回复
很好的,很不错!
line_us 2016-07-09
  • 打赏
  • 举报
回复
好像很强大的功能嘛
aa123654ss 2016-07-09
  • 打赏
  • 举报
回复
但有时候比如8G文件中 大部分数据是0xff 这样用稀疏文件也可以吗?好像它是判断是否非0
shakaqrj 2016-07-08
  • 打赏
  • 举报
回复
谢谢 但有时候比如8G文件中 大部分数据是0xff 这样用稀疏文件也可以吗?好像它是判断是否非0
schlafenhamster 2016-06-14
  • 打赏
  • 举报
回复
赵4老师 2016-06-13
  • 打赏
  • 举报
回复
Sparse File Operations [This is preliminary documentation and subject to change.] You can determine whether a file system supports sparse files by calling the GetVolumeInformation function and examining the FILE_SUPPORTS_SPARSE_FILES bit flag. Most applications are not aware of sparse-files and will not create sparse files. The fact that an application is reading a sparse file is transparent to the application. An application that is aware of sparse-files should determine whether its data set is suitable to be kept in a sparse file. After that determination is made, the application must explicitly declare a file as sparse, using the FSCTL_SET_SPARSE operation. After an application has set a file to be sparse, the application can use the FSCTL_SET_ZERO_DATA operation to set a region of the file to zero. In addition, the application can use the FSCTL_QUERY_ALLOCATED_RANGES operation to speed searches for nonzero data in the sparse file. When you perform a write operation (with a function or operation other than FSCTL_SET_ZERO_DATA) whose data consists nothing but zeros, zeros will be written to the disk for the entire length of the write. To zero out a range of the file and maintain sparseness, use FSCTL_SET_ZERO_DATA. A sparse aware application may also set an existing file to be sparse. If an application sets an existing file to be sparse, it should then scan the file for regions which contain zeros, and use FSCTL_SET_ZERO_DATA to reset those regions, and possibly deallocate some physical disk storage. An application upgraded to sparse file awareness should perform this conversion. When you perform a read operation from a zeroed-out portion of a sparse file may not read from the hard drive. Instead, the system recognizes that the portion of the file to be read contains zeros, and it returns a buffer full of zeros without actually reading from the disk. As with any other file, the system can write data to or read data from any position in a sparse file. Nonzero data being written to a previously zeroed portion of the file may result in allocation of disk space. Zeros being written over nonzero data (with FSCTL_SET_ZERO_DATA) may result in a deallocation of disk space. Note It is up to the application to maintain sparseness by writing zeros with FSCTL_SET_ZERO_DATA. Note Defragmenting tools which handle compressed files on NTFS file systems will correctly handle sparse files on NTFS 5.0 volumes.
加载更多回复(2)

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧