Files
openide/native/MacLauncher/utils.m
Roman Shevchenko 1972f691fd [platform] compilation warnings in macOS launcher
GitOrigin-RevId: 6035b3bf384d8ec255a00084944c3e5d7def5038
2021-01-27 12:30:57 +00:00

31 lines
922 B
Objective-C

// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#include "utils.h"
NSString *readFile(NSString *path) {
NSError *err = nil;
NSString *contents = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
if (contents == nil) {
debugLog([NSString stringWithFormat:@"Reading at %@ failed, Error is: %@", path, err.localizedDescription]);
return nil;
}
debugLog([NSString stringWithFormat: @"Reading at %@ OK", path]);
return contents;
}
NSString *trim(NSString *line) {
return [line stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]];
}
BOOL isDebugEnabled() {
return getenv("IDEA_LAUNCHER_DEBUG") != NULL;
}
void debugLog(NSString *message) {
if (isDebugEnabled()) {
NSLog(@"%@", message);
}
}