[REBOL] Re: How to access files ' properties under Windows
From: greggirwin:mindspring at: 19-Apr-2002 11:05
hi Christophe,
<< I'm looking for the library where I can find
the functions which access the files properties
(created/modified/accessed date, attributes, ...)
under Windows NT.
More specifically to make a file read only or to check
its read only status from a REBOL routine! >>
As Holger pointed out get-modes and set-modes are what you want to use.
Here's a little routine that might give you a start.
attr: func [
{Return current attributes for the file.}
f [file!]
/with {Retrieve only selected attributes.}
sel {Selected attributes to retrieve.}
/avail {Return a list of attributes available for the file.}
/copy {Copy all attributes, which are safe to copy, to f2.}
f2 [file!]
/local a
][
if with [return get-modes f sel]
if avail [return get-modes f 'file-modes]
if copy [
;set-modes f2 a: get-modes f get-modes f 'copy-modes
; Core 2.5 includes full-path, which it shouldn't
set-modes f2 a: get-modes f exclude get-modes f 'copy-modes
[full-path]
return a
]
get-modes f get-modes f 'file-modes
]
; >> attr/with f 'owner-write
; == true
; >> attr/with f [creation-date owner-write]
; == [creation-date: 31-Oct-2001/12:47:51-7:00 owner-write: true]
; >> attr/avail f
; == [creation-date access-date modification-date owner-write archived
hidden system f
; ull-path]
; >> attr/copy f f2
; == [creation-date: 31-Oct-2001/12:47:51-7:00 access-date:
21-Mar-2002/0:00-7:00 modi
; fication-date: 21-Mar-2002/12:11:24-7:00 owner-...
owner-write is the inverse equivalent of read-only.
HTH!
--Gregg