Page 1 of 1

File Management

Posted: Tue Jun 05, 2007 6:58 am
by andres
Hello

Is there anyway to edit the properties of an external file from Revolution.

For example check a list of files in my hard drive and mark one as read only, or hidden.

Thanks
Andres

Posted: Tue Jun 05, 2007 10:15 pm
by xApple
You might be able to access such functions using the "shell()" function.

On unix systems (like Mac OS X) you should use the "chmod" shell command to change file permissions. And to make an item invisible you just need to add a period "." as the first character of its name using the "mv" shell command.

Here is an example:

Code: Select all

get shell("mv CoolName .CoolName")
To make a file read only, you can use an AppleScript also if you are on OS X:

Code: Select all

tell application "Finder"
	set the locked of document file "CoolName" of startup disk to true
end tell
To exectue such an AppleScript in Rev, use the "do as OSALanguage" command.

Posted: Fri Aug 31, 2007 10:23 am
by oliverk
Hi Andres,

As far as i'm aware this currently does have to be done using shell commands.

In addition to those options already mentioned, on OS X systems you can use the Unix chmod command and on Windows systems you can use the attrib command. For example to make a file read only on Windows (not tested):

Code: Select all

local tResult, tShellResult
put shell("attrib +R " & quote & tFilename & quote) into tShellResult
put the result into tResult
if tResult is not 0 then
  error "Failed to make file readonly: " & tShellResult
end if
Note that when using shell commands on Windows systems, you will need to convert any file paths to Windows format. This is normally a simple matter of replace forward slashes with backslashes eg:

Code: Select all

replace "/" with "\" in tFilename
Hope this helps.

Regards
Oliver[/code]