本文整理汇总了C++中st::string::find_last方法的典型用法代码示例。如果您正苦于以下问题:C++ string::find_last方法的具体用法?C++ string::find_last怎么用?C++ string::find_last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st::string
的用法示例。
在下文中一共展示了string::find_last方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOutputDir
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());
}
示例2: filenameConvert
ST::string filenameConvert(const ST::string& filename, eDirection dir) {
if (dir == kRepack) {
fputs("Zrax broke me!\n", stderr);
abort();
}
ST::string newName = filename;
ST_ssize_t dotLoc = newName.find_last('.');
if (dotLoc < 0) {
newName += (dir == kCreate) ? ".prp" : ".prd";
} else if (dir == kCreate) {
ST::string ext = newName.substr(dotLoc);
if (ext == ".prd")
newName.replace(".prd", ".prp");
else if (ext != ".prp")
newName += ".prp";
} else {
ST::string ext = newName.substr(dotLoc);
if (ext == ".prp")
newName.replace(".prp", ".prd");
else if (ext != ".prd")
newName += ".prd";
}
return newName;
}
示例3: main
int main(int argc, char* argv[]) {
if (argc < 2 || argc > 3) {
doHelp();
return 0;
}
eDirection direction = kRepack;
ST::string filename = argv[1];
ST_ssize_t dotLoc = filename.find_last('.');
if (argc == 3) {
if (strcmp(argv[1], "-c") == 0)
direction = kCreate;
else if (strcmp(argv[1], "-x") == 0)
direction = kExtract;
else if (strcmp(argv[1], "-r") == 0)
direction = kRepack;
else {
doHelp();
return 1;
}
filename = argv[2];
} else if (dotLoc >= 0 && filename.substr(dotLoc) == ".prd") {
direction = kCreate;
}
plResManager rm;
hsFileStream S, OS;
if (!S.open(filename, fmRead)) {
ST::printf(stderr, "Error opening {} for reading!", filename);
return 1;
}
plPageInfo* page = new plPageInfo();
//int len;
short maj = 63, min = 11;
unsigned int i, j;
if (direction == kExtract || direction == kRepack) {
S.close();
delete page;
page = rm.ReadPage(filename, true);
OS.open(filenameConvert(filename, kExtract), fmCreate);
OS.write(4, "PRD");
OS.writeShort(page->getAge().size());
OS.writeStr(page->getAge());
OS.writeShort(page->getPage().size());
OS.writeStr(page->getPage());
if (rm.getVer().isUniversal()) {
maj = 0x7FFF;
min = 0x7FFF;
} else if (rm.getVer().isEoa()) {
maj = -1;
min = 1;
} else if (rm.getVer().isHexIsle()) {
maj = -1;
min = 2;
} else {
maj = rm.getVer().revMajor();
min = rm.getVer().revMinor();
}
OS.writeShort(maj);
OS.writeShort(min);
plLocation loc = page->getLocation();
loc.write(&OS);
OS.close();
std::vector<short> types = rm.getTypes(loc);
#ifdef _WIN32
CreateDirectoryW(getOutputDir(filename, page).to_wchar().data(), NULL);
#else
mkdir(getOutputDir(filename, page).c_str(), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
#endif
for (i=0; i<types.size(); i++) {
std::vector<plKey> objs = rm.getKeys(loc, types[i]);
for (j=0; j<objs.size(); j++) {
ST::string po_file = ST::format("{}[{04X}]{}.po", getOutputDir(filename, page),
types[i], CleanFileName(objs[j]->getName()));
OS.open(po_file, fmCreate);
OS.setVer(rm.getVer());
rm.WriteCreatable(&OS, objs[j]->getObj());
OS.close();
}
}
}
if (direction == kRepack) {
filename = filenameConvert(filename, kExtract);
S.open(filename, fmRead);
}
if (direction == kCreate || direction == kRepack) {
OS.open(filenameConvert(filename, kCreate), fmCreate);
char sig[4];
S.read(4, sig);
if (strncmp(sig, "PRD", sizeof(sig)) != 0) {
fputs("Error: Invalid input file!\n", stderr);
OS.close();
S.close();
return 1;
}
ST::string ageName = S.readStr(S.readShort());
ST::string pageName = S.readStr(S.readShort());
page->setAge(ageName);
//.........这里部分代码省略.........