首页 > 其他 > 详细

dlang 读取gz压缩文件

时间:2021-02-01 21:50:28      阅读:35      评论:0      收藏:0      [点我收藏+]

没找到打开gz压缩文件的标准库,暂时调用系统命令打开gz压缩文件(参考:https://dlang.org/phobos/std_process.html#.Redirect.stdoutToStderr)。

缺点是文件全部会读入内存处理,对于大文件不太友好。

 1 import std.stdio;
 2 import std.process;
 3 import std.string;
 4 
 5 void main(string[] args){
 6     string fileName = args[1];
 7     string command = "gzip -dc " ~ fileName ;
 8     auto dmd = executeShell(command);
 9     if(dmd.status != 0){
10         writeln("Compilation failed:\n", dmd.output);
11     }
12     else{
13         auto all=chomp(dmd.output).split("\n");
14             writeln(typeid(all));
15                 for(int i=0; i<all.length; i++){
16                 writeln(all[i]);
17         }
18     }
19 }

 

dlang 读取gz压缩文件

原文:https://www.cnblogs.com/mmtinfo/p/14358045.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!