Common lisp 如何在Common Lisp中获取文件大小(和其他属性)?
如何获取文件属性?我主要是希望得到的大小,但它的最后访问时间和其他属性 我只找到了获取流的Common lisp 如何在Common Lisp中获取文件大小(和其他属性)?,common-lisp,Common Lisp,如何获取文件属性?我主要是希望得到的大小,但它的最后访问时间和其他属性 我只找到了获取流的(文件长度某些文件),因此使用方式如下: (with-open-file (file "some file name") (file-length file)) 看起来是在做这项工作,但: 它得到一个流:这与api的其余部分不一致 真的没有更短的函数 (这是最有效的方式吗?) 我在中看不到任何与文件长度或属性相关的内容。也许这是它的角色,我将填写一个功能请求 谈到文件长度,并提到Osicat,仅
(文件长度某些文件)
,因此使用方式如下:
(with-open-file (file "some file name")
(file-length file))
看起来是在做这项工作,但:
- 它得到一个流:这与api的其余部分不一致
- 真的没有更短的函数
- (这是最有效的方式吗?)
stat
,可以在一个结构中得到一系列内容:
(describe (osicat-posix:stat #P"/tmp/file"))
#<OSICAT-POSIX:STAT {1004F20C93}>
[standard-object]
Slots with :INSTANCE allocation:
DEV = 2065
INO = 7349974
MODE = 33204
NLINK = 1
UID = 1000
GID = 1000
RDEV = 0
SIZE = 4304
BLKSIZE = 4096
BLOCKS = 16
ATIME = 1497626097
MTIME = 1497347216
CTIME = 1497347216
; No value
太好了,就是这样。但是它在医生里吗?我看不见。我不能使用它:
(osicat:stat
不存在(没有制表符完成或“符号stat不是外部…”)和(osicat::stat myfile)
是相反的:完成ok,但输入“函数osicat::stat未定义”:/现在不妨制作一对与文档相关的PRs…@Ehvince谢谢您的更正,这确实是错误的包
osicat-posix:stat-dev
osicat-posix:stat-gid
osicat-posix:stat-ino
osicat-posix:stat-uid
osicat-posix:stat-mode
osicat-posix:stat-rdev
osicat-posix:stat-size
osicat-posix:stat-atime
osicat-posix:stat-ctime
osicat-posix:stat-mtime
osicat-posix:stat-nlink
osicat-posix:stat-blocks
osicat-posix:stat-blksize