Page 1 of 1
locking / unlocking the front file
Posted: 2010-07-18 05:35:18
by js
I sometimes need to make an addition to a locked file, and lock it again. Is it possible to do this for the front file with a Nisus macro? If not: Can it be done by executing a shell file with a Nisus macro?
Re: locking / unlocking the front file
Posted: 2010-07-18 07:08:42
by Kino
For that purpose I'm using the macro below, to which I just added some commands for verifying the existence of
SetFile and
GetFileInfo which are required.
Code: Select all
$doc = Document.active
if $doc == undefined
exit 'No open document, exiting...'
end
$path = $doc.filePath
if $path == undefined
exit 'The frontmost document has never been saved, exiting...'
end
$locked = undefined
Set Exported Perl Variables 'path', 'locked'
Begin Perl
chomp ($SetFile = `which SetFile`);
chomp ($GetFileInfo = `which GetFileInfo`);
if ( $SetFile && $GetFileInfo) {
chomp ($locked = `GetFileInfo -al "$path"`);
if ( $locked == 1 ) {
`SetFile -a l "$path"`;
$locked = 'unlocked';
} else {
`SetFile -a L "$path"`;
$locked = 'locked';
};
};
end
if $locked == undefined
exit "SetFile or GetFileInfo not found in \$PATH.\nYou may need installing Xcode tools."
end
exit "The frontmost document has been $locked."
You can run shell commands in a Perl block as shown above.
Re: locking / unlocking the front file
Posted: 2010-07-19 06:25:09
by js
Thank you, Kino. For the moment I can't use your macro, though. I don't have the XCode tools anywhere near me. Are they an ultimate condition to lock a file out of Nisus?
Re: locking / unlocking the front file
Posted: 2010-07-19 06:52:28
by Kino
js wrote:I don't have the XCode tools anywhere near me.
Get a free ADC membership, then you can download the latest Xcode 3.2.2 for free.
Are they an ultimate condition to lock a file out of Nisus?
I don’t know. In your first posting, you mentioned “a shell file” (sic). If you have a shell script for locking/unlocking a file using other commands than SetFile and GetFileInfo, post it here.
Re: locking / unlocking the front file
Posted: 2010-07-19 07:54:13
by Hamid
Xcode is on Snow Leopard install disk.