forked from erkyrath/Inform7-IDE-Mac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIFNaturalProblem.m
35 lines (26 loc) · 1.05 KB
/
IFNaturalProblem.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// IFNaturalProblem.m
// Inform-xc2
//
// Created by Andrew Hunter on 06/10/2005.
// Copyright 2005 Andrew Hunter. All rights reserved.
//
#import "IFNaturalProblem.h"
@implementation IFNaturalProblem
- (NSURL*) urlForProblemWithErrorCode: (int) errorCode {
if (errorCode == 0) return nil; // Compiler succeeded
if (errorCode == 1) return nil; // Code 1 indicates a 'normal' failure
if (errorCode < 0) return nil; // We ignore negative return codes should they occur
// Default error page is Error0
NSString* fileURL = @"inform:/Error0.html";
// See if we've got a file for this specific error code
NSString* specificFile = [NSString stringWithFormat: @"Error%i", errorCode];
NSString* resourcePath = [[NSBundle mainBundle] pathForResource: specificFile
ofType: @"html"];
if (resourcePath != nil && [[NSFileManager defaultManager] fileExistsAtPath: resourcePath]) {
fileURL = [NSString stringWithFormat: @"inform:/%@.html", specificFile];
}
// Return the result
return [NSURL URLWithString: fileURL];
}
@end