File Management

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andres
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 68
Joined: Thu Jan 04, 2007 2:24 am

File Management

Post by andres » Tue Jun 05, 2007 6:58 am

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

xApple
Posts: 113
Joined: Wed Nov 29, 2006 10:21 pm
Location: Geneva

Post by xApple » Tue Jun 05, 2007 10:15 pm

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.

oliverk
Site Admin
Site Admin
Posts: 53
Joined: Mon Feb 27, 2006 2:16 pm
Location: Edinburgh

Post by oliverk » Fri Aug 31, 2007 10:23 am

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]
Oliver Kenyon
Software Developer
Runtime Revolution

Post Reply

Return to “Talking LiveCode”