00. 目录
01. 命令概述
zipinfo命令的全称为“zip information”,该命令用于列出压缩文件信息。执行zipinfo指令可得知zip压缩文件的详细信息。
02. 命令格式
zipinfo [-12hlmMstTvz][压缩文件][文件...][-x <范本样式>]
- 1
03. 常用选项
-1:只列出文件名称;
-2:此参数的效果和指定“-1”参数类似,但可搭配“-h”,“-t”和“-z”参数使用;
-h:只列出压缩文件的文件名称;
-l:此参数的效果和指定“-m”参数类似,但会列出原始文件的大小而非每个文件的压缩率;
-m:此参数的效果和指定“-s”参数类似,但多会列出每个文件的压缩率;
-M:若信息内容超过一个画面,则采用类似more指令的方式列出信息;
-s:用类似执行“ls-l”指令的效果列出压缩文件内容;
-t:只列出压缩文件内所包含的文件数目,压缩前后的文件大小及压缩率;
-T:将压缩文件内每个文件的日期时间用年,月,日,时,分,秒的顺序列出;
-v:详细显示压缩文件内每一个文件的信息;
-x<范本样式>:不列出符合条件的文件的信息;
-z:如果压缩文件内含有注释,就将注释显示出来。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
04. 参考示例
4.1 显示压缩文件信息
[deng@localhost test]$ zipinfo file.zip
Archive: file.zip
Zip file size: 1610 bytes, number of entries: 4
-rwxrwxr-x 3.0 unx 520 tx defN 19-Jul-28 21:59 a.sh
-rwxrwxr-x 3.0 unx 520 tx defN 19-Jul-28 21:59 b.sh
-rwxrwxr-x 3.0 unx 520 tx defN 19-Jul-28 21:59 c.sh
-rwxrwxr-x 3.0 unx 520 tx defN 19-Jul-28 21:59 d.sh
4 files, 2080 bytes uncompressed, 1044 bytes compressed: 49.8%
[deng@localhost test]$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
4.2 显示压缩文件中每个文件的信息
[deng@localhost test]$ zipinfo -v file.zip
Archive: file.zip
There is no zipfile comment.
End-of-central-directory record:
-------------------------------
Zip archive file size: 1610 (000000000000064Ah)
Actual end-cent-dir record offset: 1588 (0000000000000634h)
Expected end-cent-dir record offset: 1588 (0000000000000634h)
(based on the length of the central directory and its expected offset)
This zipfile constitutes the sole disk of a single-part archive; its
central directory contains 4 entries.
The central directory is 296 (0000000000000128h) bytes long,
and its (expected) offset in bytes from the beginning of the zipfile
is 1292 (000000000000050Ch).
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
4.3 只显示压缩包大小、文件数目
[deng@localhost test]$ zipinfo -h file.zip
Archive: file.zip
Zip file size: 1610 bytes, number of entries: 4
[deng@localhost test]$
- 1
- 2
- 3
- 4
4.4 生成一个基本的、长格式的列表,包括标题和总计行
[deng@localhost test]$ zipinfo -l file.zip
Archive: file.zip
Zip file size: 1610 bytes, number of entries: 4
-rwxrwxr-x 3.0 unx 520 tx 261 defN 19-Jul-28 21:59 a.sh
-rwxrwxr-x 3.0 unx 520 tx 261 defN 19-Jul-28 21:59 b.sh
-rwxrwxr-x 3.0 unx 520 tx 261 defN 19-Jul-28 21:59 c.sh
-rwxrwxr-x 3.0 unx 520 tx 261 defN 19-Jul-28 21:59 d.sh
4 files, 2080 bytes uncompressed, 1044 bytes compressed: 49.8%
[deng@localhost test]$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
4.5 将压缩文件内每个文件的日期时间用年,月,日,时,分,秒的顺序列出
[deng@localhost test]$ zipinfo -T file.zip
Archive: file.zip
Zip file size: 1610 bytes, number of entries: 4
-rwxrwxr-x 3.0 unx 520 tx defN 20190728.215900 a.sh
-rwxrwxr-x 3.0 unx 520 tx defN 20190728.215906 b.sh
-rwxrwxr-x 3.0 unx 520 tx defN 20190728.215909 c.sh
-rwxrwxr-x 3.0 unx 520 tx defN 20190728.215913 d.sh
4 files, 2080 bytes uncompressed, 1044 bytes compressed: 49.8%
[deng@localhost test]$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
4.6 查看存档中最近修改的文件,排序列出
[deng@localhost test]$ zipinfo -T file.zip | sort -nr -k 7
-rwxrwxr-x 3.0 unx 520 tx defN 20190728.215913 d.sh
-rwxrwxr-x 3.0 unx 520 tx defN 20190728.215909 c.sh
-rwxrwxr-x 3.0 unx 520 tx defN 20190728.215906 b.sh
-rwxrwxr-x 3.0 unx 520 tx defN 20190728.215900 a.sh
Zip file size: 1610 bytes, number of entries: 4
Archive: file.zip
4 files, 2080 bytes uncompressed, 1044 bytes compressed: 49.8%
[deng@localhost test]$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
05. 附录
基本概念
内存管理模块管理系统的内存资源,它是操作系统的核心模块之一,主要包括内存的初始化、分配以及释放。
在系统运行过程中,内存管理模块通过对内存的申请/释放来管理用户和OS对内存的使用,使内存的利用率和使用效率达到最优,同时最大限度地解决系统的内存碎片问题。
OpenHarmony LiteOS-M的内存管理分为静态内存管理和动态内存管理,提供内存初始化、分配、释放等功能。
-
动态内存:在动态内存池中分配用户指定大小的内存块。
- 优点:按需分配。
- 缺点:内存池中可能出现碎片。
-
静态内存:在静态内存池中分配用户初始化时预设(固定)大小的内存块。
- 优点:分配和释放效率高,静态内存池中无碎片。
- 缺点:只能申请到初始化预设大小的内存块,不能按需申请。
静态内存
运行机制
静态内存实质上是一个静态数组,静态内存池内的块大小在初始化时设定,初始化后块大小不可变更。
静态内存池由一个控制块LOS_MEMBOX_INFO和若干相同大小的内存块LOS_MEMBOX_NODE构成。控制块位于内存池头部,用于内存块管理,包含内存块大小uwBlkSize,内存块数量uwBlkNum,已分配使用的内存块数量uwBlkCnt和空闲内存块链表stFreeList。内存块的申请和释放以块大小为粒度,每个内存块包含指向下一个内存块的指针pstNext。
图1 静态内存示意图
开发指导
使用场景
当用户需要使用固定长度的内存时,可以通过静态内存分配的方式获取内存,一旦使用完毕,通过静态内存释放函数归还所占用内存,使之可以重复使用。
接口说明
OpenHarmony LiteOS-M的静态内存管理主要为用户提供以下功能,接口详细信息可以查看API参考。
表1 静态内存模块接口
class="table-box">功能分类 | 接口名 |
---|---|
初始化静态内存池 | LOS_MemboxInit:初始化一个静态内存池,根据入参设定其起始地址、总大小及每个内存块大小。 |
清除静态内存块内容 | LOS_MemboxClr:清零从静态内存池中申请的静态内存块的内容。 |
申请、释放静态内存 | LOS_MemboxAlloc:从指定的静态内存池中申请一块静态内存块。 LOS_MemboxFree:释放从静态内存池中申请的一块静态内存块。 |
获取、打印静态内存池信息 | LOS_MemboxStatisticsGet:获取指定静态内存池的信息,包括内存池中总内存块数量、已经分配出去的内存块数量、每个内存块的大小。 LOS_ShowBox:打印指定静态内存池所有节点信息,打印等级是LOG_INFO_LEVEL(当前打印等级配置是PRINT_LEVEL),包括内存池起始地址、内存块大小、总内存块数量、每个空闲内存块的起始地址、所有内存块的起始地址。 |
评论记录:
回复评论: