2

I am planning to convert a rather long shell script I have into an Objective C command line tool. I'm planning to use NSTask to run the shell commands (this is a large script, and it has several thousand copy/move/delete operations). My question is, will continually allocating and deallocating NSTask objects to run all these commands result in a large performance hit?

Is there a better way to do it than using NSTask?

Thanks

indragie
  • 18,002
  • 16
  • 95
  • 164
  • Can you explain why you want to do this? It's a little difficult to see point of converting a shell script to an Objective-C program, so it's hard to say what the best way is to go about it. – Chuck Sep 21 '09 at 01:26
  • 1
    The main reason is that I want to protect my shell script from being opened and read like an open book by the user (especially since this is a shareware app). Just need a way to protect the code. – indragie Sep 21 '09 at 01:31

1 Answers1

3

If you're just moving/copying/deleting files, have you considered using NSFileManager?

mipadi
  • 398,885
  • 90
  • 523
  • 479
  • I forgot to mention also that I need to set permissions on files. Is that possible with NSFileManager? – indragie Sep 21 '09 at 01:56
  • 1
    Assuming the CLI is running with the perms to do so, then yes. It's in `-[NSFileManager setAttributes:ofItemAtPath:error:]`. – Dave DeLong Sep 21 '09 at 02:21