dlang 读取gz压缩文件
2024-10-20 07:47:50
没找到打开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 }
最新文章
- 一鼓作气 博客--第七篇 note7
- input---checked小问题
- WP8图片缩放功能实现
- struts2文件上传和下载
- PHP面向对象——重写与重载
- ArcGis实现添加MultiLayerMarkerSymbol(多个符号叠加生成新的符号)
- 欧拉工程第56题:Powerful digit sum
- TortoiseGit&#39;s Settings
- Successfully installed matplotlib
- LaTex 下编译后不能显示中文,或者中文乱码
- 【Cocos2d-x 粒子系统】火球用手指飞起来
- java传值和通过引用传递
- 使用CXF开发JAX-WS类型的WebService
- AVFoundation 框架初探究(二)
- Spring-Security自定义登录页&;inMemoryAuthentication验证
- 深入 JAVA里面关于byte数组和String之间的转换问题
- [Swift]LeetCode885. 螺旋矩阵 III | Spiral Matrix III
- WPF自定义控件(三)の扩展控件
- docker-machine on azure
- Jvm 性能检测