本文整理汇总了C++中common::String::lastChar方法的典型用法代码示例。如果您正苦于以下问题:C++ String::lastChar方法的具体用法?C++ String::lastChar怎么用?C++ String::lastChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::String
的用法示例。
在下文中一共展示了String::lastChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: concatWithSavesPath
Common::String DefaultSaveFileManager::concatWithSavesPath(Common::String name) {
DefaultSaveFileManager *manager = dynamic_cast<DefaultSaveFileManager *>(g_system->getSavefileManager());
Common::String path = (manager ? manager->getSavePath() : ConfMan.get("savepath"));
if (path.size() > 0 && (path.lastChar() == '/' || path.lastChar() == '\\'))
return path + name;
//simple heuristic to determine which path separator to use
int backslashes = 0;
for (uint32 i = 0; i < path.size(); ++i)
if (path[i] == '/') --backslashes;
else if (path[i] == '\\') ++backslashes;
if (backslashes > 0) return path + '\\' + name;
return path + '/' + name;
}
示例2: start
void SavesSyncRequest::start() {
//cleanup
_ignoreCallback = true;
if (_workingRequest)
_workingRequest->finish();
_currentDownloadingFile = StorageFile();
_currentUploadingFile = "";
_filesToDownload.clear();
_filesToUpload.clear();
_localFilesTimestamps.clear();
_totalFilesToHandle = 0;
_ignoreCallback = false;
//load timestamps
_localFilesTimestamps = DefaultSaveFileManager::loadTimestamps();
//list saves directory
Common::String dir = _storage->savesDirectoryPath();
if (dir.lastChar() == '/')
dir.deleteLastChar();
_workingRequest = _storage->listDirectory(
dir,
new Common::Callback<SavesSyncRequest, Storage::ListDirectoryResponse>(this, &SavesSyncRequest::directoryListedCallback),
new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::directoryListedErrorCallback)
);
if (!_workingRequest) finishError(Networking::ErrorResponse(this));
}
示例3: directoryListedErrorCallback
void SavesSyncRequest::directoryListedErrorCallback(Networking::ErrorResponse error) {
_workingRequest = nullptr;
if (_ignoreCallback)
return;
bool irrecoverable = error.interrupted || error.failed;
if (error.failed) {
Common::JSONValue *value = Common::JSON::parse(error.response.c_str());
if (value) {
if (value->isObject()) {
Common::JSONObject object = value->asObject();
//Dropbox-related error:
if (object.contains("error_summary") && object.getVal("error_summary")->isString()) {
Common::String summary = object.getVal("error_summary")->asString();
if (summary.contains("not_found")) {
irrecoverable = false;
}
}
//OneDrive-related error:
if (object.contains("error") && object.getVal("error")->isObject()) {
Common::JSONObject errorNode = object.getVal("error")->asObject();
if (Networking::CurlJsonRequest::jsonContainsString(errorNode, "code", "SavesSyncRequest")) {
Common::String code = errorNode.getVal("code")->asString();
if (code == "itemNotFound") {
irrecoverable = false;
}
}
}
}
delete value;
}
//Google Drive and Box-related ScummVM-based error
if (error.response.contains("subdirectory not found")) {
irrecoverable = false; //base "/ScummVM/" folder not found
} else if (error.response.contains("no such file found in its parent directory")) {
irrecoverable = false; //"Saves" folder within "/ScummVM/" not found
}
}
if (irrecoverable) {
finishError(error);
return;
}
//we're lucky - user just lacks his "/cloud/" folder - let's create one
Common::String dir = _storage->savesDirectoryPath();
if (dir.lastChar() == '/')
dir.deleteLastChar();
debug(9, "SavesSyncRequest: creating %s", dir.c_str());
_workingRequest = _storage->createDirectory(
dir,
new Common::Callback<SavesSyncRequest, Storage::BoolResponse>(this, &SavesSyncRequest::directoryCreatedCallback),
new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::directoryCreatedErrorCallback)
);
if (!_workingRequest)
finishError(Networking::ErrorResponse(this));
}
示例4: FSNODE
Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path) {
dbg_printf("NEW FSNODE(%s)\n", path.c_str());
_path = path;
if (path.empty()) {
_isHere = true;
_isDirectory = true; /* root is always a dir */
_isRoot = true;
_displayName = Common::String("PlayStation 2");
_verified = true;
} else if (path.lastChar() == ':') {
_isHere = true;
_isDirectory = true; /* devs are always a dir */
_isRoot = false;
_displayName = getDeviceDescription();
_verified = true;
} else {
_verified = false;
doverify();
if (!_isHere)
return;
_displayName = _lastPathComponent(_path);
if (_isDirectory && _path.lastChar() != '/')
_path+= '/';
_isRoot = false;
}
}
示例5: parse
bool LabelCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
if (line.lastChar() != ':') {
return false;
}
Common::String label = line;
label.deleteLastChar();
LabelCommand *labelCmd = new LabelCommand(label);
if (!parseCtx._labels.contains(label)) {
parseCtx._labels[label] = labelCmd;
} else {
warning("Label '%s' already exists", label.c_str());
}
if (parseCtx._pendingGotos.contains(label)) {
GotoCommands &gotos = parseCtx._pendingGotos[label];
for (GotoCommands::const_iterator it = gotos.begin(); it != gotos.end(); ++it) {
(*it)->setLabelCommand(labelCmd);
}
gotos.clear();
}
command = labelCmd;
return true;
}
示例6: themeConfigParseHeader
bool ThemeEngine::themeConfigParseHeader(Common::String header, Common::String &themeName) {
// Check that header is not corrupted
if ((byte)header[0] > 127) {
warning("Corrupted theme header found");
return false;
}
header.trim();
if (header.empty())
return false;
if (header[0] != '[' || header.lastChar() != ']')
return false;
header.deleteChar(0);
header.deleteLastChar();
Common::StringTokenizer tok(header, ":");
if (tok.nextToken() != SCUMMVM_THEME_VERSION_STR)
return false;
themeName = tok.nextToken();
Common::String author = tok.nextToken();
return tok.empty();
}
示例7: goUp
void RemoteBrowserDialog::goUp() {
if (_rememberedNodeContents.contains(_node.path()))
_rememberedNodeContents.erase(_node.path());
Common::String path = _node.path();
if (path.size() && (path.lastChar() == '/' || path.lastChar() == '\\'))
path.deleteLastChar();
if (path.empty()) {
_rememberedNodeContents.erase("");
} else {
for (int i = path.size() - 1; i >= 0; --i)
if (i == 0 || path[i] == '/' || path[i] == '\\') {
path.erase(i);
break;
}
}
listDirectory(Cloud::StorageFile(path, 0, 0, true));
}
示例8: getSavePath
Common::InSaveFile *GBAMPSaveFileManager::openForLoading(const Common::String &filename) {
Common::String fileSpec = getSavePath();
if (fileSpec.lastChar() != '/')
fileSpec += '/';
fileSpec += filename;
// consolePrintf("Opening the file: %s\n", fileSpec.c_str());
return DS::DSFileStream::makeFromPath(fileSpec, false);
}
示例9: OutSaveFile
Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &filename, bool compress) {
Common::String fileSpec = getSavePath();
if (fileSpec.lastChar() != '/')
fileSpec += '/';
fileSpec += filename;
// consolePrintf("Opening the file: %s\n", fileSpec.c_str());
Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true);
// Use a write buffer
stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE);
return new OutSaveFile(stream);
}
示例10: newPath
AbstractFSNode *WindowsFilesystemNode::getChild(const Common::String &n) const {
assert(_isDirectory);
// Make sure the string contains no slashes
assert(!n.contains('/'));
Common::String newPath(_path);
if (_path.lastChar() != '\\')
newPath += '\\';
newPath += n;
return new WindowsFilesystemNode(newPath, false);
}
示例11: newPath
BadaFilesystemNode::BadaFilesystemNode(const Common::String &root,
const Common::String &nodePath) {
// Make sure the string contains no slashes
AppAssert(!nodePath.contains('/'));
// We assume here that path is already normalized (hence don't bother to
// call Common::normalizePath on the final path).
Common::String newPath(root);
if (root.lastChar() != '/') {
newPath += '/';
}
newPath += nodePath;
init(newPath);
}
示例12: resStrLen
Common::String ScummEngine_v60he::convertFilePath(const byte *src) {
debug(2, "convertFilePath in: '%s'", (const char *)src);
int srcSize = resStrLen(src);
int start = 0;
if (srcSize > 2) {
if (src[0] == ':') { // Game Data Path (Macintosh)
// The default game data path is set to ':' by ScummVM
start = 1;
} else if (src[0] == '.' && src[1] == '\\') { // Game Data Path (Windows)
// The default game data path is set to '.\\' by ScummVM
start = 2;
} else if (src[0] == '*' && src[1] == '\\') { // Save Game Path (Windows HE72 - HE100)
// The default save game path is set to '*\\' by ScummVM
start = 2;
} else if (src[0] == '*' && src[1] == ':') { // Save Game Path (Macintosh HE72 - HE100)
// The default save game path is set to '*:' by ScummVM
start = 2;
} else if (src[0] == 'c' && src[1] == ':') { // Save Game Path (HE60 - HE71)
// The default save path is game path (DOS) or 'c:\\hegames\\' (Windows)
for (start = srcSize; start != 0; start--)
if (src[start - 1] == '\\')
break;
} else if (src[0] == 'u' && src[1] == 's') { // Save Game Path (Moonbase Commander)
// The default save path is 'user\\'
start = 5;
}
}
Common::String dst;
for (int i = start; i < srcSize; i++) {
// Convert path separators
if (src[i] == '\\' || src[i] == ':')
dst += '/';
else
dst += src[i];
}
// Sanity check
if (dst.lastChar() == '/')
dst.deleteLastChar();
debug(2, "convertFilePath out: '%s'", dst.c_str());
return dst;
}
示例13: normalizePath
Common::String normalizePath(const Common::String &path, const char sep) {
if (path.empty())
return path;
const char *cur = path.c_str();
Common::String result;
// If there is a leading slash, preserve that:
if (*cur == sep) {
result += sep;
while (*cur == sep)
++cur;
}
// Scan till the end of the String
while (*cur != 0) {
const char *start = cur;
// Scan till the next path separator resp. the end of the string
while (*cur != sep && *cur != 0)
cur++;
const Common::String component(start, cur);
// Skip empty components and dot components, add all others
if (!component.empty() && component != ".") {
// Add a separator before the component, unless the result
// string already ends with one (which happens only if the
// path *starts* with a separator).
if (!result.empty() && result.lastChar() != sep)
result += sep;
// Add the component
result += component;
}
// Skip over separator chars
while (*cur == sep)
cur++;
}
return result;
}
示例14: composeFileHashMap
static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth, const char * const *directoryGlobs) {
if (depth <= 0)
return;
if (fslist.empty())
return;
// First we compose a hashmap of all files in fslist.
// Includes nifty stuff like removing trailing dots and ignoring case.
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory()) {
Common::FSList files;
if (!directoryGlobs)
continue;
bool matched = false;
for (const char * const *glob = directoryGlobs; *glob; glob++)
if (file->getName().matchString(*glob, true)) {
matched = true;
break;
}
if (!matched)
continue;
if (!file->getChildren(files, Common::FSNode::kListAll))
continue;
composeFileHashMap(files, allFiles, depth - 1, directoryGlobs);
}
Common::String tstr = file->getName();
// Strip any trailing dot
if (tstr.lastChar() == '.')
tstr.deleteLastChar();
allFiles[tstr] = *file; // Record the presence of this file
}
}
示例15: themeConfigParseHeader
bool ThemeEngine::themeConfigParseHeader(Common::String header, Common::String &themeName) {
header.trim();
if (header.empty())
return false;
if (header[0] != '[' || header.lastChar() != ']')
return false;
header.deleteChar(0);
header.deleteLastChar();
Common::StringTokenizer tok(header, ":");
if (tok.nextToken() != RESIDUAL_THEME_VERSION_STR)
return false;
themeName = tok.nextToken();
Common::String author = tok.nextToken();
return tok.empty();
}