//----------------------------------------------------------------------- void UnicodeFileSystemArchive::FileFinder::run(const WString& _wpattern, bool _recursive, bool _dirs, StringVector* _simpleList, FileInfoList* _detailList) { mRecursive = _recursive; mDirs = _dirs; mSimpleList = _simpleList; mDetailList = _detailList; // pattern can contain a directory name, separate it from mask size_t pos1 = _wpattern.rfind ('/'); size_t pos2 = _wpattern.rfind ('\\'); if (pos1 == _wpattern.npos || ((pos2 != _wpattern.npos) && (pos1 < pos2))) pos1 = pos2; WString wdir, wmask; if(pos1 == String::npos) { wmask = _wpattern; } else { wdir = _wpattern.substr(0, pos1 + 1); wmask = _wpattern.substr(pos1 + 1); } if(wmask == L"*") wmask.clear(); String mask = mArchive->toString(wmask); String dir = mArchive->toString(wdir); WString wFullDir = mArchive->getFullPath(wdir); _run(dir, wFullDir); }
void wsplit( TVectorWString & _outStrings, const WString& _str, bool _trimDelims, const WString& _delims ) { uint32_t numSplits = 0; WString::size_type start = 0; WString::size_type pos = 0; do { pos = _str.find_first_of(_delims, start); if (pos == WString::npos ) { _outStrings.push_back( _str.substr(start) ); break; } else { _outStrings.push_back( _str.substr(start, pos - start) ); start = pos + 1; } if( _trimDelims == true ) { start = _str.find_first_not_of(_delims, start); } ++numSplits; } while (pos != WString::npos); }
// // Remove szOlds from the end of the string. // WString WString::TrimEnd ( const wchar_t* szOld ) const { const size_t uiOldLength = wcslen ( szOld ); WString strResult = *this; while ( strResult.length () >= uiOldLength && strResult.substr ( strResult.length () - uiOldLength ) == szOld ) strResult = strResult.substr ( 0, strResult.length () - uiOldLength ); return strResult; }
// // Remove szOlds from the start of the string. // WString WString::TrimStart ( const wchar_t* szOld ) const { const size_t uiOldLength = wcslen ( szOld ); WString strResult = *this; while ( strResult.substr ( 0, uiOldLength ) == szOld ) strResult = strResult.substr ( uiOldLength ); return strResult; }
void GUIStatusBar::setScene(const WString& name, bool modified) { WStringStream content; content << L"Scene: "; if (name.size() > 15) content << name.substr(0, 15) << L"..."; else content << name; if (modified) content << L"*"; mScene->setContent(HString(content.str())); }
void GUIStatusBar::setProject(const WString& name, bool modified) { WStringStream content; content << L"Project: "; if (name.size() > 20) content << name.substr(0, 20) << L"..."; else content << name; if (modified) content << L"*"; mProject->setContent(HString(content.str())); }
void GUIStatusBar::logModified() { LogEntry entry; if(!gDebug().getLog().getLastEntry(entry)) { GUIContent messageContent(HString(L"")); mMessage->setContent(messageContent); return; } HSpriteTexture iconTexture; Color textColor = COLOR_INFO; UINT32 logChannel = entry.getChannel(); switch (logChannel) { case (UINT32)DebugChannel::Debug: iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Info, 16, false); break; case (UINT32)DebugChannel::Warning: case (UINT32)DebugChannel::CompilerWarning: iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Warning, 16, false); textColor = COLOR_WARNING; break; case (UINT32)DebugChannel::Error: case (UINT32)DebugChannel::CompilerError: iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Error, 16, false); textColor = COLOR_ERROR; break; } WString message = toWString(entry.getMessage()); size_t lfPos = message.find_first_of('\n'); size_t crPos = message.find_first_of('\r'); size_t newlinePos; if (lfPos != WString::npos) { if (crPos != WString::npos) newlinePos = std::min(lfPos, crPos); else newlinePos = lfPos; } else if (crPos != WString::npos) newlinePos = crPos; else newlinePos = -1; if (newlinePos == -1) { GUIContent messageContent(HString(message), iconTexture); mMessage->setContent(messageContent); mMessage->setTint(textColor); } else { WString firstLine = message.substr(0, newlinePos); GUIContent messageContent(HString(firstLine), iconTexture); mMessage->setContent(messageContent); mMessage->setTint(textColor); } }
SharedPtr<FormatBase> FormatBase::loadImport(const String &filename, int architecture) { if(File::isPathExists(filename)) return ::loadImport(filename, architecture); List<String> searchPaths; String currentDirectory = WStringToString(Win32NativeHelper::get()->getCurrentDirectory()); searchPaths.push_back(currentDirectory.substr(0, currentDirectory.length() - 1)); #ifdef _WIN32 wchar_t *environmentBlock = Win32NativeHelper::get()->getEnvironments(); WString path; while(*environmentBlock) { size_t equal = 0; size_t currentLength = 0; wchar_t *start = environmentBlock; while(*environmentBlock ++) { if(*environmentBlock == L'=') equal = currentLength; currentLength ++; } if(equal >= 3 && WString::to_lower(start[0]) == L'p' && WString::to_lower(start[1]) == L'a' && WString::to_lower(start[2]) == L't' && WString::to_lower(start[3]) == L'h' && start[4] == L'=') { path.assign(start + equal + 2); break; } } int s = 0, e = 0; while(true) { e = path.find(L';', e + 1); if(e == -1) break; String currentPath = WStringToString(path.substr(s, e - s)); searchPaths.push_back(currentPath); s = e + 1; } #endif for(auto &i : searchPaths) { String path = File::combinePath(i, filename); SharedPtr<FormatBase> result = ::loadImport(path, architecture); if(!result) { if(path.substr(path.length() - 4).icompare(".dll") != 0) { path.append(".dll"); result = ::loadImport(path, architecture); } } if(result.get()) return result; } return SharedPtr<FormatBase>(nullptr); }