在boost::filesystem中是否有为路径提供文件系统类型的方法;
$ stat -f -L -c %T .
ext2/ext3我不一定需要字符串。枚举值就可以了。
发布于 2012-02-22 15:24:20
我不认为boost提供了任何查询文件系统类型的方法。但是,您可能需要使用statfs函数来实现此目的。从手册页-
函数的作用是:返回已挂载文件系统的相关信息。path是挂载的文件系统中任何文件的路径名。buf是指向statfs结构的指针,其定义大致如下:
struct statfs {
__SWORD_TYPE f_type; /* type of file system (see below) */
__SWORD_TYPE f_bsize; /* optimal transfer block size */
fsblkcnt_t f_blocks; /* total data blocks in file system */
fsblkcnt_t f_bfree; /* free blocks in fs */
fsblkcnt_t f_bavail; /* free blocks available to
unprivileged user */
fsfilcnt_t f_files; /* total file nodes in file system */
fsfilcnt_t f_ffree; /* free file nodes in fs */
fsid_t f_fsid; /* file system id */
__SWORD_TYPE f_namelen; /* maximum length of filenames */
__SWORD_TYPE f_frsize; /* fragment size (since Linux 2.6) */
__SWORD_TYPE f_spare[5];
};https://stackoverflow.com/questions/9319457
复制相似问题