mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
use NSFileManager for checking script existance
This commit is contained in:
parent
c9af96eb43
commit
cc8c2c686c
1 changed files with 3 additions and 6 deletions
|
@ -809,17 +809,14 @@ tr_session * fHandle;
|
||||||
|
|
||||||
- (void) setDoneScriptEnabled: (id) sender
|
- (void) setDoneScriptEnabled: (id) sender
|
||||||
{
|
{
|
||||||
if ([fDefaults boolForKey: @"DoneScriptEnabled"] && !fopen([[fDefaults stringForKey:@"DoneScriptPath"] UTF8String], "r"))
|
if ([fDefaults boolForKey: @"DoneScriptEnabled"] && ![[NSFileManager defaultManager] fileExistsAtPath: [fDefaults stringForKey:@"DoneScriptPath"]])
|
||||||
{
|
{
|
||||||
// enabled is set but script file doesn't exist, so prompt for one and disable until they pick one
|
// enabled is set but script file doesn't exist, so prompt for one and disable until they pick one
|
||||||
[fDefaults setBool: NO forKey: @"DoneScriptEnabled"];
|
[fDefaults setBool: NO forKey: @"DoneScriptEnabled"];
|
||||||
[self doneScriptSheetShow: sender];
|
[self doneScriptSheetShow: sender];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
tr_sessionSetTorrentDoneScriptEnabled(fHandle, [fDefaults boolForKey: @"DoneScriptEnabled"]);
|
tr_sessionSetTorrentDoneScriptEnabled(fHandle, [fDefaults boolForKey: @"DoneScriptEnabled"]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setAutoImport: (id) sender
|
- (void) setAutoImport: (id) sender
|
||||||
{
|
{
|
||||||
|
@ -1358,7 +1355,7 @@ tr_session * fHandle;
|
||||||
{
|
{
|
||||||
NSString * filePath = [[openPanel filenames] objectAtIndex: 0];
|
NSString * filePath = [[openPanel filenames] objectAtIndex: 0];
|
||||||
|
|
||||||
if (fopen([filePath UTF8String], "r")) // script file exists
|
if ([[NSFileManager defaultManager] fileExistsAtPath: filePath]) // script file exists
|
||||||
{
|
{
|
||||||
[fDefaults setObject: filePath forKey: @"DoneScriptPath"];
|
[fDefaults setObject: filePath forKey: @"DoneScriptPath"];
|
||||||
[fDefaults setBool: YES forKey: @"DoneScriptEnabled"];
|
[fDefaults setBool: YES forKey: @"DoneScriptEnabled"];
|
||||||
|
|
Loading…
Reference in a new issue