本文整理汇总了C++中String::Chr方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Chr方法的具体用法?C++ String::Chr怎么用?C++ String::Chr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Chr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QuoteStr
void WINAPI QuoteStr(String& str)
{
String buff;
if(str.Chr(quotes) == -1)
return;
buff.Add('\"');
for(int n = 0; n < str.Length(); n++)
if(str[n] == '\"')
{
buff.Add('\"');
buff.Add('\"');
}
else
buff.Add(str[n]);
buff.Add('\"');
str = buff;
}
示例2: FTPCreateDirectory
BOOL FTP::FTPCreateDirectory(LPCSTR dir,int OpMode)
{
String Command;
int len = (int)strlen(dir);
if(!len)
return FALSE;
len--;
Assert(hConnect && "FtpCreateDirectory");
do
{
//Try relative path
if(!isspace(dir[len]))
{
hConnect->CacheReset();
Command.printf("mkdir \x1%s\x1", dir);
if(hConnect->ProcessCommand(Command))
break;
}
//Try relative path with end slash
hConnect->CacheReset();
Command.printf("mkdir \x1%s/\x1", dir);
if(hConnect->ProcessCommand(Command))
break;
//Try absolute path
if(!isspace(dir[len]))
{
Command.printf("mkdir \x1%s/%s\x1",
hConnect->SToOEM(hConnect->CurDir).c_str(), dir + (dir[0] == '/'));
if(hConnect->ProcessCommand(Command))
break;
}
//Try absolute path with end slash
Command.printf("mkdir \x1%s/%s/\x1",
hConnect->SToOEM(hConnect->CurDir).c_str(), dir + (dir[0] == '/'));
if(hConnect->ProcessCommand(Command))
break;
//Noone work
return FALSE;
}
while(0);
if(!IS_SILENT(OpMode))
{
int b = Command.Chr('\x1'),
e = Command.Chr('\x1', b+1);
if(b == -1)
SelectFile = "";
else if(e == -1)
SelectFile.Set(Command.c_str(), b+1, -1);
else
SelectFile.Set(Command.c_str(), b+1, e);
}
return TRUE;
}
示例3: AddToQueque
void FTP::AddToQueque(FAR_FIND_DATA* FileName, LPCSTR Path, BOOL Download)
{
String str;
char *m;
int num;
FTPUrl* p = new FTPUrl;
memcpy(&p->Host, &Host, sizeof(Host));
p->Download = Download;
p->Next = NULL;
p->FileName = *FileName;
p->Error.Null();
p->DestPath = Path;
if(Download)
m = strrchr(FileName->cFileName, '/');
else
m = strrchr(FileName->cFileName, '\\');
if(m)
{
*m = 0;
p->DestPath.Add(m);
memmove(FileName->cFileName, m+1, m-FileName->cFileName);
}
if(Download)
{
GetCurPath(p->SrcPath);
AddEndSlash(p->SrcPath, '/');
str.printf("%s%s", p->SrcPath.c_str(), FileName->cFileName);
FixLocalSlash(p->DestPath);
AddEndSlash(p->DestPath, '\\');
num = str.Chr('/');
}
else
{
PanelInfo pi;
FP_Info->Control(this, FCTL_GETANOTHERPANELINFO, &pi);
p->SrcPath = pi.CurDir;
AddEndSlash(p->SrcPath, '\\');
str.printf("%s%s", p->SrcPath.c_str(), FileName->cFileName);
FixLocalSlash(str);
AddEndSlash(p->DestPath, '/');
num = str.Chr('\\');
}
if(num != -1)
{
StrCpy(p->FileName.cFileName, str.c_str()+num+1, ARRAYSIZE(p->FileName.cFileName));
str.SetLength(num);
p->SrcPath = str;
}
else
{
StrCpy(p->FileName.cFileName, str.c_str(), ARRAYSIZE(p->FileName.cFileName));
p->SrcPath.Null();
}
if(!UrlsList) UrlsList = p;
if(UrlsTail) UrlsTail->Next = p;
UrlsTail = p;
QuequeSize++;
}