本文整理汇总了C++中Inode::DisableFileCache方法的典型用法代码示例。如果您正苦于以下问题:C++ Inode::DisableFileCache方法的具体用法?C++ Inode::DisableFileCache怎么用?C++ Inode::DisableFileCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inode
的用法示例。
在下文中一共展示了Inode::DisableFileCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transaction
static status_t
ext2_open(fs_volume* _volume, fs_vnode* _node, int openMode, void** _cookie)
{
Volume* volume = (Volume*)_volume->private_volume;
Inode* inode = (Inode*)_node->private_node;
// opening a directory read-only is allowed, although you can't read
// any data from it.
if (inode->IsDirectory() && (openMode & O_RWMASK) != 0)
return B_IS_A_DIRECTORY;
status_t status = inode->CheckPermissions(open_mode_to_access(openMode)
| (openMode & O_TRUNC ? W_OK : 0));
if (status != B_OK)
return status;
// Prepare the cookie
file_cookie* cookie = new(std::nothrow) file_cookie;
if (cookie == NULL)
return B_NO_MEMORY;
ObjectDeleter<file_cookie> cookieDeleter(cookie);
cookie->open_mode = openMode & EXT2_OPEN_MODE_USER_MASK;
cookie->last_size = inode->Size();
cookie->last_notification = system_time();
MethodDeleter<Inode, status_t> fileCacheEnabler(&Inode::EnableFileCache);
if ((openMode & O_NOCACHE) != 0) {
status = inode->DisableFileCache();
if (status != B_OK)
return status;
fileCacheEnabler.SetTo(inode);
}
// Should we truncate the file?
if ((openMode & O_TRUNC) != 0) {
if ((openMode & O_RWMASK) == O_RDONLY)
return B_NOT_ALLOWED;
Transaction transaction(volume->GetJournal());
inode->WriteLockInTransaction(transaction);
status_t status = inode->Resize(transaction, 0);
if (status == B_OK)
status = inode->WriteBack(transaction);
if (status == B_OK)
status = transaction.Done();
if (status != B_OK)
return status;
// TODO: No need to notify file size changed?
}
fileCacheEnabler.Detach();
cookieDeleter.Detach();
*_cookie = cookie;
return B_OK;
}