示例#1
0
void plResponderModifier::ILog(uint32_t color, const char* format, ...)
{
#ifdef STATUS_LOG
    if (!gLog)
        gLog = plStatusLogMgr::GetInstance().CreateStatusLog(15, "Responder", plStatusLog::kFilledBackground | plStatusLog::kDeleteForMe | plStatusLog::kDontWriteFile | plStatusLog::kAlignToTop);

    if (!format || *format == '\0')
        return;

    ST::string keyName = GetKeyName();

    // Make sure this key isn't in our list of keys to deny
    for (const auto& it : gNoLogStrings) {
        if (keyName.starts_with(it))
            return;
    }

    // Format the log text
    char buf[256];
    va_list args;
    va_start(args, format);
    int numWritten = hsVsnprintf(buf, sizeof(buf), format, args);
    hsAssert(numWritten > 0, "Buffer too small");
    va_end(args);

    // Strip the redundant part off the key name
    ST_ssize_t modPos = keyName.find("_ResponderModifier");
    if (modPos != -1)
        keyName = keyName.left(modPos);

    ST::string logLine = ST::format("{}: {}", keyName, buf);
    gLog->AddLine(logLine.c_str(), color);
#endif // STATUS_LOG
}
示例#2
0
ST::string cdUp(ST::string path) {
    // Check for root paths, we can't go up from there!
#ifdef _WIN32
    if (path.substr(1) == ":\\")
        return path;
#else
    if (path == "/")
        return path;
#endif

    // Not very robust, but it works for one level of parent scanning
    if (path.is_empty())
        return ".." PATHSEPSTR;

    // Strip the ending slash, if necessary, and then go up one dir
    if (path.char_at(path.size()-1) == PATHSEP)
        path = path.left(path.size() - 1);
    ST::string up = path.before_last(PATHSEP);
    if (path.char_at(0) == PATHSEP) {
        // Absolute path specified -- make sure we keep it that way
        return up + PATHSEPSTR;
    } else {
        // Relative path specified
        return up.is_empty() ? "" : up + PATHSEPSTR;
    }
}
示例#3
0
ST::string getOutputDir(const ST::string& filename, plPageInfo* page) {
    ST::string odir = filename;
    ST_ssize_t sepLoc = odir.find_last(PATHSEP);
    if (sepLoc < 0)
        odir = ST::string();
    else
        odir = odir.left(sepLoc + 1);
    return odir + ST::format("{}_{}_PRP" PATHSEPSTR, page->getAge(), page->getPage());
}