Stroka TFileCollection::DebugString() const { Stroka ret; for (size_t i = 0; i < Files.size(); ++i) { ret.append(Files[i]->Name()).append(" ->"); for (size_t j = 0; j < Files[i]->Aliases().size(); ++j) ret.append(' ').append(Files[i]->Aliases()[j]); ret.append('\n'); } return ret; }
Stroka StripFileComponent(const Stroka& fileName) { Stroka dir = IsDir(fileName) ? fileName : GetDirName(fileName); if (!dir.empty() && dir.back() != GetDirectorySeparator()) { dir.append(GetDirectorySeparator()); } return dir; }
void SlashFolderLocal(Stroka &folder) { if (!folder) return; #ifdef _win32_ size_t pos; while ((pos = folder.find('/')) != Stroka::npos) folder.replace(pos, 1, LOCSLASH_S); #endif if (folder[+folder-1] != LOCSLASH_C) folder.append(LOCSLASH_S); }
inline Stroka Load<Stroka>(TInputStream* in) { size_t len = Load<ui32>(in); Stroka ret; TTempBuf tmp; while (len) { const size_t toread = Min(len, tmp.Size()); const size_t readed = in->Read(tmp.Data(), toread); if (!readed) { ythrow yexception() << "malformed archive"; } ret.append(tmp.Data(), readed); len -= readed; } return ret; }
Stroka EncodeXMLString(const char* str) { Stroka strout; if (!str) return Stroka(); char num[15]; num[14] = 0; num[13] = ';'; for (const char* s = str, *s1; *s;) { for (s1 = s; safe_chars[(unsigned char)(*s1)]; s1++) ; if (s1 != s) strout.replace(+strout, 0, s, 0, s1 - s, s1 - s); s = s1; if (*s == 0) break; strout.replace(+strout, 0, "&#", 0, 2, 2); char *p = &num[13]; for (int code = csYandex.unicode[(unsigned char)(*s++)]; code > 0; code /= 10) *(--p) = '0' + (code % 10); strout.append(p); } return strout; }