Rebol 编程/exists-thru?
外观
< Rebol 编程
EXISTS-THRU? url /check info
检查磁盘缓存中是否存在文件。返回:none,false(已过期)或文件
EXISTS-THRU? 是一个函数值。
- url -- (类型:url 文件)
- /check -- 检查缓存文件的版本、校验和/安全、日期和/或大小。
- info -- (类型:块 元组 二进制 逻辑 日期 none)
exists-thru?: func [ {Checks if a file is in the disk cache. Returns: none, false (out of date), or file} url [url! file!] /check {Checks version, checksum/secure, date, and/or size of cached file.} info [block! tuple! binary! logic! date! none!] /local file data date ][ if not file: path-thru url [return none] if not exists? file [return false] if not check [return file] if none? info [return file] if tuple? info [ if not data: attempt [load/header script? file] [return none] if all [ object? data: data/1 tuple? data/version data/version >= info ] [return file] return false ] if binary? info [ if not data: attempt [read/binary file] [return none] if info = checksum/secure data [return file] return false ] if not block? info [info: reduce [info]] foreach item info [ if date? item [ date: get-modes file 'modification-date if (date + 0:00:03) < item [return false] ] if integer? item [ if item <> size? file [return false] ] ] file ]