在Poco库中,封装了一些类去完成文件系统的操作,这些类包括:
1. Poco::Path
2. Poco::File
3. Poco::TemporaryFile
4. Poco::DirectoryIterator
5. Poco::Glob
1. Poco::Path
1.1 路径:
1. 在不同操作系统中,指明文件和目录所在位置的标示符是不一样的。2. 标示符的不一致,会造成代码在不同平台之间移植的困难。
3. Poco::Path类抽象了不同标识符之间的区别,使程序员可以把注意力集中在业务的开发上。
4. Poco::Path类支持Windows、Unix、OpenVMS操作系统。
1.2 Poco路径简介:
Poco中的路径包括了 :1. 一个可选的节点(node)名:
a) 在Windows上,这是计算机在UNC( Universal Naming Convention )路径中的名字
b) 在OpenVMS中,这代表一个集群系统中的节点名
c) 在Unix中,此名字未被使用。
2. 一个可选的设备(device)名:
a) 在Windows上,这是一个驱动器盘符
b) 在OpenVMS上,这是存储盘符的名字
c) 在Unix,此名字未被使用。
3. 一个目录名的列表
4. 一个文件名(包括扩展名)和版本号(OpenVMS特有)
Poco支持两种路径 :
1. 绝对路径
以根目录为起点的描述资源的目录
2. 相对目录
以某一个确定路径为起点的描述资源的目录(通常这是用户的当前目录)
相对目录可以被转换为绝对目录(反之,并不成立)。
在Poco中路径的指向可以是一个目录也可以是一个文件。当路径指向目录时,文件名为空。
下面是Poco中关于路径的一些例子:
Path: C:\Windows\system32\cmd.exe
Style: Windows
Kind: absolute, to file
Node Name: –
Device Name: C
Directory List: Windows, system32
File Name: cmd.exe
File Version: –
Path: Poco\Foundation\
Style: Windows
Kind: relative, to directory
Node Name: –
Device Name: –
Directory List: Poco, Foundation
File Name: –
File Version: –
Path: \\www\site\index.html
Style: Windows
Kind: absolute, to file
Node Name: www
Device Name: –
Directory List: site
File Name: index.html
File Version: –
Path: /usr/local/include/Poco/Foundation.h
Style: Unix
Kind: absolute, to file
Node Name: –
Device Name: –
Directory List: usr, local, include, Poco
File Name: index.html
File Version: –
Path: ../bin/