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);
39 XPLMGetSystemPath(xplanePath);
41 if (XPLMIsFeatureEnabled(
"XPLM_USE_NATIVE_PATHS") == 0)
43 HFS2PosixPath(xplanePath, xplanePath,
sizeof(xplanePath));
47 g_sep = XPLMGetDirectorySeparator();
52 void Logger::print(
const std::string &filePath,
int line, MsgType type,
const std::string &message)
58 assert(!filePath.empty());
59 std::ostringstream ss;
62 #if defined(XSWIFTBUS_ENABLE_TRACE_LOG)
65 case DebugMsg: ss <<
"Debug";
break;
66 case InfoMsg: ss <<
"Info";
break;
67 case WarningMsg: ss <<
"Warning";
break;
68 case ErrorMsg: ss <<
"Error";
break;
72 std::string seperator =
"/\\";
73 std::size_t sepPos = filePath.find_last_of(seperator);
74 if (sepPos != std::string::npos) { ss << filePath.substr(sepPos + 1, filePath.size() - 1); }
75 else { ss << filePath; }
85 const std::string buffer = ss.str();
86 XPLMDebugString(buffer.c_str());
93 CFSmartPtr(T p) : p_(p) {}
96 if (p_) CFRelease(p_);
98 operator T() {
return p_; }
103 # pragma clang diagnostic push
104 # pragma clang diagnostic ignored "-Wdeprecated-declarations"
107 int HFS2PosixPath(
const char *path,
char *result,
int resultLen)
109 bool is_dir = (path[strlen(path) - 1] ==
':');
111 CFSmartPtr<CFStringRef> inStr(CFStringCreateWithCString(kCFAllocatorDefault, path, kCFStringEncodingMacRoman));
112 if (inStr ==
nullptr)
return -1;
114 CFSmartPtr<CFURLRef> url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, inStr, kCFURLHFSPathStyle, 0));
115 if (url ==
nullptr)
return -1;
117 CFSmartPtr<CFStringRef> outStr(CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle));
118 if (outStr ==
nullptr)
return -1;
120 if (!CFStringGetCString(outStr, result, resultLen, kCFStringEncodingMacRoman))
return -1;
122 if (is_dir) strcat(result,
"/");
128 # 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.