本文整理汇总了C++中OovString::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ OovString::resize方法的具体用法?C++ OovString::resize怎么用?C++ OovString::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OovString
的用法示例。
在下文中一共展示了OovString::resize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getBinDirectory
OovString const Project::getBinDirectory()
{
static OovString path;
if(path.length() == 0)
{
OovStatus status(true, SC_File);
#ifdef __linux__
char buf[300];
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf));
if(len >= 0)
{
buf[len] = '\0';
path = buf;
size_t pos = path.rfind('/');
if(pos == std::string::npos)
{
pos = path.rfind('\\');
}
if(pos != std::string::npos)
{
path.resize(pos+1);
}
}
/*
if(FileIsFileOnDisk("./oovaide", status))
{
path = "./";
}
else if(FileIsFileOnDisk("/usr/local/bin/oovaide", status))
{
path = "/usr/local/bin/";
}
*/
else
{
path = "/usr/bin";
}
#else
if(FileIsFileOnDisk("./oovaide.exe", status))
{
path = "./";
}
else
{
path = FilePathGetDrivePath(sArgv0);
}
#endif
if(status.needReport())
{
status.report(ET_Error, "Unable to get bin directory");
}
}
return path;
}
示例2: getLine
bool NameValueRecord::getLine(File &file, OovString &str, OovStatus &status)
{
char lineBuf[1000];
str.resize(0);
// Read many times until the \n is found.
while(file.getString(lineBuf, sizeof(lineBuf), status))
{
str += lineBuf;
size_t len = str.length();
if(str[len-1] == '\n')
{
str.resize(len-1);
break;
}
else if(len > 50000)
{
break;
}
}
return(str.length() > 0);
}
示例3: FileEnsurePathExists
OovStatusReturn FileEnsurePathExists(OovStringRef const path)
{
OovStatus status(true, SC_File);
FilePath fullPath(path, FP_Dir);
FilePath existingPath = fullPath;
if(fullPath.find('~') == std::string::npos)
{
// Walk up the tree to find a base that exists.
size_t pos = existingPath.getPosEndDir();
while(pos != 0 && pos != std::string::npos)
{
existingPath.discardTail(pos);
OovStatus ignoredStatus(true, SC_File);
if(existingPath.isDirOnDisk(ignoredStatus))
break;
else
pos = existingPath.getPosLeftPathSep(pos, RP_RetPosFailure);
}
if(pos == std::string::npos)
{
pos = 0;
}
while(pos != std::string::npos && status.ok())
{
pos = findPathSep(fullPath, pos);
if(pos != std::string::npos)
{
OovString partPathStr = fullPath;
partPathStr.resize(pos);
if(!FileIsDirOnDisk(partPathStr, status))
{
status = FileMakeSubDir(partPathStr);
}
pos++;
}
}
}
else
{
status.set(false, SC_Logic);
}
return status;
}
示例4: appendNames
void CMaker::appendNames(OovStringVec const &names,
char delim, OovString &str)
{
for(auto const &name : names)
{
str += name;
str += delim;
size_t startpos = str.rfind('\n');
if(startpos == std::string::npos)
startpos = 0;
if(str.length() - startpos > 70)
{
str += "\n ";
}
}
int len = str.length();
if(len > 0 && str[len-1] == delim)
str.resize(len-1);
}
示例5: FileEnsurePathExists
bool FileEnsurePathExists(OovStringRef const path)
{
bool success = true;
// Walk up the tree to find a base that exists.
FilePath fp(path, FP_File);
size_t pos = fp.getPosEndDir();
while(pos != 0)
{
fp.discardTail(pos);
bool ignoredSuccess = true;
if(fp.isDirOnDisk(ignoredSuccess))
break;
else
pos = fp.getPosLeftPathSep(pos, RP_RetPosFailure);
}
while(pos != std::string::npos && pos != 0 && success)
{
pos = findPathSep(path, pos);
if(pos != std::string::npos)
{
OovString partPath = path;
partPath.resize(pos);
if(!FileIsDirOnDisk(partPath, success))
{
#ifdef __linux__
success = (mkdir(partPath.getStr(), 0x1FF) == 0); // 0777
#else
success = (_mkdir(partPath.getStr()) == 0);
#endif
}
pos++;
}
}
return success;
}