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 arguments types on the command line ...
Get Programming in Objective-C, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.