Determining if a Mac OS X directory is locked

Yennie at aol.com Yennie at aol.com
Wed May 28 03:11:01 EDT 2003


Ken, Tom,

I'm not sure this is as complete as it needs to be- the permission bits in 
characters 2 through 10 consist of 3 groups of permissions: 3 chars for the 
owner of the file, 3 for the group, and 3 for all others. On a multi-user MacOS X 
system, for example, you would find that each user's desktop is writable by 
the owner, but looks read-only to anyone else. In that case, looking for a "w" 
anywhere in the permissions would give the false impression that other users' 
desktop are writable by you.

You can get the owner of the file, the group, and the permissions from the 
"detailed files" listing.

Using the original "ls" command, you could try starting with something like 
this if you are on OS X or UNIX systems:

put shell("ls -ld"&&fileOrFolderPath) into theInfo
put word 1 of theInfo into thePermissions
put word 2 of theInfo into fOwner
put word 3 of theInfo into fGroup
put word 1 of shell("who am i") into thisUser
...

Getting back to the original question... it seems the quickest way to 
determine if you can write to a directory may simply be to do this:

open file (someDirectory&"/myfiletest")
if (there is a file (someDirectory&"/myfiletest")) then
   put TRUE into isWritable
   close file (someDirectory&"/myfiletest")
   delete file (someDirectory&"/myfiletest")
else
   put FALSE into isWritable
end if

Hopefully some of that helps!

> function IsReadOnly pWhat
>   -- Go to the home folder, then the Desktop
>   -- folder inside, then get a listing
>   put shell("cd ~;cd desktop;ls -l") into temp
>   put lineOffset(space & pWhat &cr,temp) into tLine
>   put char 2 to 10 of word 1 of tLine into tAccessModes
>   return ("w" is in tAccessModes)
> end IsReadOnly
> 





------------------------------
Brian Yennie
Chief Technology Officer
QLD Learning, LLC
www.QLDLearning.com

PH: (904)-997-0212
EMAIL: Yennie at aol.com
-------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20030528/a4d25308/attachment.html>


More information about the use-livecode mailing list