void ForceDir(const char* dir) { if (dir != NULL) { const char* startDir = dir; #if defined(CFG_OS_WINDOWS) // Skip "X:" (if dir is Windows file path) if (startDir[0] != '\0' && startDir[1] == ':') startDir += 2; #endif // Skip \\ and // (if dir is network path) while (IsPathDelimiter(*startDir)) ++startDir; // Split path into parts and add server name if dir is network path MultiString dirs(startDir, FILE_PATH_DELIMITERS, NULL); std::string path(dir, startDir - dir); int i = 0; if (startDir != dir && dirs.word_count() > 0) // if dir is network path { path.append(dirs.word(0)); i = 1; } // Create directories while (i < dirs.word_count()) { path = JoinPath(path.c_str(), dirs.word(i)); if (!DirExists(path.c_str())) CreateDir(path.c_str()); ++i; } } else throw CreateArgumentNullException(); }
void EventImpl::Invoke(void* args) { if (args != NULL) { if (m_Handlers != NULL) { bool b = m_InvokeInProgress; m_InvokeInProgress = true; try { Sys::InvokeDefaultHandler(m_Handlers, args); // this is more effective, than this->InvokeDefaultHandler(); } catch (...) { m_InvokeInProgress = b; if (!m_InvokeInProgress) DeleteDetachedDelegates(); throw; } m_InvokeInProgress = b; if (!m_InvokeInProgress) DeleteDetachedDelegates(); } } else throw CreateArgumentNullException(); }
void CreateDir(const char* dir) { if (dir != NULL) { if (mkdir_x(dir) != 0) throw CreateRtlException(dir); } else throw CreateArgumentNullException(); }
std::string GetNextToken(const char** str, const char* delimiters, const char* spaces) { std::string result; if (str != NULL) { const char* s = SkipChars(*str, spaces); const char* t = FindChars(s, delimiters); const char* r = t; if (!IsEmpty(t)) { while (t > s && ContainsChar(spaces, *(t - 1))) { --t; } } result.assign(s, t); *str = SkipChars(r, delimiters); } else throw CreateArgumentNullException(); return result; }