1

您好我在从按钮执行 Unix 命令时遇到问题。

这是我到目前为止所拥有的:

> #import <Cocoa/Cocoa.h>
> 
> @interface  PUPController : NSWindow { }
> - (IBAction)OpenPUP:(id)PUPC;
> - (IBAction)DestinationFolder:(id)PUPC;
> - (IBAction)Exit:(id)PUPC;
> - (IBAction)Unpack:(id)PUPC;
> 
> @end
> 
> #import "OPDFPUE.h"
> 
> @implementation PUPController
> 
> - (IBAction)OpenPUP:(id)PUPC; {
>     NSArray* fileTypes = [[NSArray alloc] initWithObjects:@"PUP", nil];
>     NSOpenPanel* openDlg = [NSOpenPanel openPanel];
>     [openDlg setCanChooseFiles:YES];
>     [openDlg setCanChooseDirectories:NO];
>     [openDlg setAllowsMultipleSelection:NO];
>     [openDlg setMessage:@"Select Playsation 3 System Software Update (PUP) File for Extraction"];
>     if ( [openDlg runModalForTypes:fileTypes] == NSOKButton )
>     {
>         NSArray* files = [openDlg filenames];
>     }
>     NSString * tvarDirectory = [openDlg directory];
>     NSString * tvarFilename = [openDlg filename]; }
> 
> - (IBAction)DestinationFolder:(id)PUPC; {
>     NSSavePanel *saveDlg  = [NSSavePanel savePanel];
>     [saveDlg setMessage:@"Select folder to save extracted contents of the Playsation 3 System Software Update (PUP) File selected"];
>     int tvarInt   = [saveDlg runModal];
>   
>     if(tvarInt == NSOKButton){
>     }
>     else if(tvarInt == NSCancelButton) {
>     return;
>     }
>     else {
>     return;
>     }
>     NSString * tvarDirectory = [saveDlg directory];
>     NSString * tvarFilename = [saveDlg filename]; }
> 
> - (IBAction)Exit:(id)PUPC; {
>     exit(0); } NSTask *pupunpack;
> 
> - (IBAction)Unpack:(id)PUPC {
>     
>     pupunpack=[[NSTask alloc] init];
>     [pupunpack setLaunchPath:@"/usr/bin/pupunpack"];
>     [pupunpack launch];
>      }
>      
>      - (id)init {
>     
>      } @end

如果有人可以提供帮助,那就太好了。基本上我正在做的是插入一个文件,设置目标然后程序将解压缩该文件。我有一个打开的对话框来选择一个 pup 文件,然后是一个保存对话框来选择保存目标。然后我有一个解压按钮,它目前什么都不做。解压按钮需要参数。如果有人可以提供帮助,那就太好了。

我是Objective-C的新手,我试图找到尽可能多的信息,但我似乎无法让它发挥作用。这是我正在使用的 unix 应用程序。

https://dl.dropbox.com/u/43729201/pupunpack.zip

4

1 回答 1

0

您可能需要将文件名和目标目录添加为命令参数:

[pupunpack setArguments:[NSArray arrayWithObjects:tVarFilename, tvarDirectory, nil]];
于 2012-11-20T11:58:35.463 回答