O'Reilly logo

Programming in Objective-C, Sixth Edition by Stephen G. Kochan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Copying Files and Using the NSProcessInfo Class

Program 16.6 illustrates a command-line tool to implement a simple file copy operation. Usage of this command is as follows:

copy from-file to-file

Unlike NSFileManager’s copyPath:toPath:handler: method, your command-line tool enables to-file to be a directory name. In that case, the file is copied into the to-file directory under the name from-file. Also unlike the method, if to-file already exists, you allow its contents to be overwritten. This is more in line with the standard UNIX copy command cp.

You can get the filenames from the command line by using the argc and argv arguments to main. These two arguments are populated, respectively, with the number of argument types on the command line ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required