std::string BusClient::appConfDir(const MojString& appId, PackageType type, PackageLocation location) { MojLogTrace(m_log); std::string confPath; switch (location) { case System: confPath = "/"; break; case ThirdParty: confPath = BASE_CRYPTOFS; break; } confPath += BASE_PALM_OFFSET; switch (type) { case Application: confPath += APPS_DIR; break; case Service: confPath += SERVICES_DIR; break; } confPath.append(appId.begin(), appId.end()); if (access(confPath.c_str(), R_OK) != 0) { m_wrongAplication = true; } return confPath + CONF_SUBDIR; }
MojErr MojDbIndex::validateName(const MojString& name) { if (name.length() > MaxIndexNameLen) { MojErrThrowMsg(MojErrDbInvalidIndexName, _T("db: index name '%s' invalid: length is %zd chars, max is %zd"), name.data(), name.length(), MaxIndexNameLen); } for (MojString::ConstIterator i = name.begin(); i < name.end(); ++i) { if (!MojIsAlNum(*i) && *i != _T('_')) { MojErrThrowMsg(MojErrDbInvalidIndexName, _T("db: index name '%s' invalid: char at position %zd not allowed"), name.data(), (MojSize) (i - name.begin())); } } return MojErrNone; }
MojErr MojDbTextUtils::unicodeToStr(const UChar* src, MojSize len, MojString& destOut) { MojAssert(src || len == 0); MojErr err = destOut.resize(len * 2); MojErrCheck(err); MojInt32 destCapacity = 0; MojInt32 destLength = 0; do { MojChar* dest = NULL; err = destOut.begin(dest); MojErrCheck(err); destCapacity = (MojInt32) destOut.length(); UErrorCode status = U_ZERO_ERROR; u_strToUTF8(dest, destCapacity, &destLength, src, (MojInt32) len, &status); if (status != U_BUFFER_OVERFLOW_ERROR) MojUnicodeErrCheck(status); err = destOut.resize(destLength); MojErrCheck(err); } while (destLength > destCapacity); return MojErrNone; }