locking / unlocking the front file
locking / unlocking the front file
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
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.
You can run shell commands in a Perl block as shown above.
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."
Re: locking / unlocking the front file
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
Get a free ADC membership, then you can download the latest Xcode 3.2.2 for free.js wrote:I don't have the XCode tools anywhere near me.
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.Are they an ultimate condition to lock a file out of Nisus?
Re: locking / unlocking the front file
Xcode is on Snow Leopard install disk.