本文整理汇总了C++中JString::AllocateCString方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::AllocateCString方法的具体用法?C++ JString::AllocateCString怎么用?C++ JString::AllocateCString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::AllocateCString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
JError
JCreateTempFile
(
const JCharacter* path,
const JCharacter* prefix,
JString* fullName
)
{
JString p;
if (!JStringEmpty(path))
{
p = path;
}
else if (!JGetTempDirectory(&p))
{
return JDirEntryDoesNotExist("/tmp");
}
if (!JStringEmpty(prefix))
{
p = JCombinePathAndName(p, prefix);
}
else
{
p = JCombinePathAndName(p, "temp_file_");
}
p += "XXXXXX";
char* s = p.AllocateCString();
jclear_errno();
int fd = mkstemp(s);
if (fd != -1)
{
close(fd);
*fullName = s;
delete [] s;
return JNoError();
}
fullName->Clear();
delete [] s;
// EINVAL counts as unexpected
const int err = jerrno();
if (err == EEXIST)
{
return JAccessDenied(p);
}
else
{
return JUnexpectedError(err);
}
}
示例2: if
JError
JCreateTempDirectory
(
const JCharacter* path,
const JCharacter* prefix,
JString* fullName
)
{
JString p;
if (!JStringEmpty(path))
{
p = path;
}
else if (!JGetTempDirectory(&p))
{
return JDirEntryDoesNotExist("/tmp");
}
if (!JStringEmpty(prefix))
{
p = JCombinePathAndName(p, prefix);
}
else
{
p = JCombinePathAndName(p, "temp_dir_");
}
p += "XXXXXX";
char* s = p.AllocateCString();
jclear_errno();
char* d = mkdtemp(s);
if (d != NULL)
{
*fullName = s;
JAppendDirSeparator(fullName);
delete [] s;
return JNoError();
}
fullName->Clear();
delete [] s;
// EINVAL counts as unexpected
const int err = jerrno();
if (err == EEXIST)
{
return JDirEntryAlreadyExists(p);
}
else if (err == EFAULT)
{
return JSegFault();
}
else if (err == EACCES)
{
return JAccessDenied(p);
}
else if (err == ENAMETOOLONG)
{
return JNameTooLong();
}
else if (err == ENOENT)
{
return JBadPath(p);
}
else if (err == ENOTDIR)
{
return JComponentNotDirectory(p);
}
else if (err == ENOMEM)
{
return JNoKernelMemory();
}
else if (err == EROFS)
{
return JFileSystemReadOnly();
}
else if (err == ELOOP)
{
return JPathContainsLoop(p);
}
else if (err == ENOSPC)
{
return JFileSystemFull();
}
else
{
return JUnexpectedError(err);
}
}