如何在dolist循环中返回路径名-名称?

问题描述 投票:0回答:1

我试图用从目录结构派生的路径名列表填充哈希表。结构如下:

├── audio
│   ├── aliinaMay23 -> /home/kf/mySamples/aliinaMay23
│   ├── alla -> /home/kf/mySamples/UpSitDown/alla
│   ├── aluminumBangs -> /home/kf/mySamples/aluminumBangs
│   ├── bd -> /home/kf/mySamples/bd/
│   ├── beachWaveLoop -> /home/kf/mySamples/beachWaveLoop
│   ├── blowBubbles -> /home/kf/mySamples/blowBubbles
│   ├── bodyPerc -> /home/kf/mySamples/bodyPerc
... etc

如果我尝试打印出单个目录名,它会起作用,但是当我循环目录列表时,我只会得到 nil。我在这里缺少什么?

(print (pathname-name "audio/bd")) ; prints out "bd", as expected

(dolist (dir (uiop:subdirectories "audio"))
  (print (pathname dir))) ; prints out the pathnames of the subfolders, as expected

(dolist (dir (uiop:subdirectories "audio"))
  (print (pathname-name dir))) ; prints out one nil per subfolder. Why?
common-lisp
1个回答
0
投票

啊,这有效:

(dolist (dir (uiop:subdirectories "audio"))   
  (print (first (last (pathname-directory dir)))))
© www.soinside.com 2019 - 2024. All rights reserved.