12#include <XPLM/XPLMPlugin.h>
13#include <XPLM/XPLMUtilities.h>
14#include <XPMPMultiplayer.h>
21# include <Carbon/Carbon.h>
30 int HFS2PosixPath(
const char *path,
char *result,
int resultLen);
42 XPLMGetSystemPath(xplanePath);
44 if (XPLMIsFeatureEnabled(
"XPLM_USE_NATIVE_PATHS") == 0)
46 HFS2PosixPath(xplanePath, xplanePath,
sizeof(xplanePath));
50 g_sep = XPLMGetDirectorySeparator();
55 void Logger::print(
const std::string &filePath,
int line, MsgType type,
const std::string &message)
61 assert(!filePath.empty());
62 std::ostringstream ss;
65#if defined(XSWIFTBUS_ENABLE_TRACE_LOG)
68 case DebugMsg: ss <<
"Debug";
break;
69 case InfoMsg: ss <<
"Info";
break;
70 case WarningMsg: ss <<
"Warning";
break;
71 case ErrorMsg: ss <<
"Error";
break;
75 std::string seperator =
"/\\";
76 std::size_t sepPos = filePath.find_last_of(seperator);
77 if (sepPos != std::string::npos)
79 ss << filePath.substr(sepPos + 1, filePath.size() - 1);
94 const std::string buffer = ss.str();
95 XPLMDebugString(buffer.c_str());
102 CFSmartPtr(T p) : p_(p) {}
105 if (p_) CFRelease(p_);
107 operator T() {
return p_; }
112# pragma clang diagnostic push
113# pragma clang diagnostic ignored "-Wdeprecated-declarations"
116 int HFS2PosixPath(
const char *path,
char *result,
int resultLen)
118 bool is_dir = (path[strlen(path) - 1] ==
':');
120 CFSmartPtr<CFStringRef> inStr(CFStringCreateWithCString(kCFAllocatorDefault, path, kCFStringEncodingMacRoman));
121 if (inStr ==
nullptr)
return -1;
123 CFSmartPtr<CFURLRef> url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, inStr, kCFURLHFSPathStyle, 0));
124 if (url ==
nullptr)
return -1;
126 CFSmartPtr<CFStringRef> outStr(CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle));
127 if (outStr ==
nullptr)
return -1;
129 if (!CFStringGetCString(outStr, result, resultLen, kCFStringEncodingMacRoman))
return -1;
131 if (is_dir) strcat(result,
"/");
137# pragma clang diagnostic pop
static void print(const std::string &filePath, int line, MsgType type, const std::string &message)
Print message to X-Plane log.
Plugin loaded by X-Plane which publishes a DBus service.
std::string g_xplanePath
Absolute xplane path.
std::string g_sep
Platform specific dir separator.
void initXPlanePath()
Init global xplane path.