nisus.com
https://www.nisus.com/forum/

locking / unlocking the front file
https://www.nisus.com/forum/viewtopic.php?f=17&t=3822
Page 1 of 1

Author:  js [ 2010-07-18 05:35:18 ]
Post subject:  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?

Author:  Kino [ 2010-07-18 07:08:42 ]
Post subject:  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.
Code:
$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.

Author:  js [ 2010-07-19 06:25:09 ]
Post subject:  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?

Author:  Kino [ 2010-07-19 06:52:28 ]
Post subject:  Re: locking / unlocking the front file

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.
Quote:
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.

Author:  Hamid [ 2010-07-19 07:54:13 ]
Post subject:  Re: locking / unlocking the front file

Xcode is on Snow Leopard install disk.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/