当前位置:软件学习 > 其它软件 >>

ELisp编程四:文件操作

上一篇:http://www.zzzyk.com/kf/201204/127815.html

确定一个文件是否存在
[plain]
(file-exists-p "~/test.el") 

看看它的帮助文档:
[plain]
file-exists-p is a built-in function in `C source code'. 
 
(file-exists-p FILENAME) 
 
Return t if file FILENAME exists (whether or not you can read it.) 
See also `file-readable-p' and `file-attributes'. 
This returns nil for a symlink to a nonexistent file. 
Use `file-symlink-p' to test for such links. 

如果存在则返回t

检查一个文件是否存在且可读
[plain]
(file-readable-p "~/test.el") 


检查文件的属性
[plain]
(file-attributes "~/test.el" 'string) 

或者
[plain]
(file-attributes "~/test.el" 'integer) 

上面两行list以字符串或者整数list的形式显示文件的属性,从0-11,一共12个属性。
可以通过这个获得一个文件是否是目录的信息。


摘自 sheismylife的专栏
补充:软件开发 , 其他 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,