Rebol 程式設計/rm
外觀
RM target /any
刪除指定的檔案。
RM 是一個函式值。
- target -- 要刪除的檔案(型別:檔案 URL)
- /any -- 允許萬用字元
- 捕獲
rm: func [
"Deletes the specified file(s)."
[catch]
target [file! url!] "the file to delete"
/any "allow wild cards"
/local p dir blk file ret err
][
dir: throw-on-error [open first p: split-path clean-path target]
error? set/any 'err try [
either any [
blk: copy dir
foreach file blk [
ret: find/match/any file second p
if none? ret [ret: file]
either tail? ret [
remove dir
] [
dir: next dir
]
]
] [
blk: copy dir
either not none? blk: find blk second p [
remove skip dir (index? blk) - 1
] [
make error! reduce ['access 'no-delete target]
]
]
]
attempt [close dir]
either error? get/any 'err [throw err] [get/any 'err]
]