本文整理汇总了C++中BEntry::set方法的典型用法代码示例。如果您正苦于以下问题:C++ BEntry::set方法的具体用法?C++ BEntry::set怎么用?C++ BEntry::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEntry
的用法示例。
在下文中一共展示了BEntry::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _Rename
/*! \brief Renames the BEntry to path, replacing an existing entry if clobber is true.
NOTE: The BEntry must refer to an existing file. If it is abstract, this method will fail.
\param path Pointer to a string containing the new name for the entry. May
be absolute or relative. If relative, the entry is renamed within its
current directory.
\param clobber If \c false and a file with the name given by \c path already exists,
the method will fail. If \c true and such a file exists, it will
be overwritten.
\return
- \c B_OK - Success
- \c B_ENTRY_EXISTS - The new location is already taken and \c clobber was \c false
- \c B_ENTRY_NOT_FOUND - Attempted to rename an abstract entry
- "error code" - Failure
*/
status_t
BEntry::Rename(const char *path, bool clobber)
{
// check parameter and initialization
if (path == NULL)
return B_BAD_VALUE;
if (fCStatus != B_OK)
return B_NO_INIT;
// get an entry representing the target location
BEntry target;
status_t error;
if (BPrivate::Storage::is_absolute_path(path)) {
error = target.SetTo(path);
} else {
int dirFD = _kern_dup(fDirFd);
if (dirFD < 0)
return dirFD;
// init the entry
error = target.fCStatus = target.set(dirFD, path, false);
}
if (error != B_OK)
return error;
return _Rename(target, clobber);
}