Reply to topic  [ 5 posts ] 
locking / unlocking the front file 
Author Message

Joined: 2007-04-12 14:59:36
Posts: 229
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?


2010-07-18 05:35:18
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
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.


2010-07-18 07:08:42
Profile

Joined: 2007-04-12 14:59:36
Posts: 229
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?


2010-07-19 06:25:09
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
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.


2010-07-19 06:52:28
Profile
User avatar

Joined: 2007-01-17 03:25:42
Posts: 729
Xcode is on Snow Leopard install disk.


2010-07-19 07:54:13
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software