blob: 63c392282044b7d889c39ca60fbe6b9114dceed0 [file] [log] [blame]
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -08001#include "utils.h"
2
3NSString *readFile(NSString *path) {
4 NSError *err = nil;
5 NSString *contents = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
6 if (contents == nil) {
7 debugLog([NSString stringWithFormat:@"Reading at %@ failed, Error is: %@", path, err.localizedDescription]);
8 return nil;
9 }
10
11 debugLog([NSString stringWithFormat: @"Reading at %@ OK", path]);
12
13 return contents;
14}
15
16NSString *trim(NSString *line) {
17 return [line stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]];
18}
19
20BOOL isDebugEnabled() {
21 return getenv("IDEA_LAUNCHER_DEBUG") != NULL;
22}
23
24void debugLog(NSString *message) {
25 if (isDebugEnabled()) {
26 NSLog(@"%@", message);
27 }
28}
29
30