本文整理汇总了C++中Volume类的典型用法代码示例。如果您正苦于以下问题:C++ Volume类的具体用法?C++ Volume怎么用?C++ Volume使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Volume类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: packagefs_read_index_dir
status_t
packagefs_read_index_dir(fs_volume* fsVolume, void* cookie,
struct dirent* buffer, size_t bufferSize, uint32* _num)
{
Volume* volume = (Volume*)fsVolume->private_volume;
FUNCTION("volume: %p, cookie: %p, buffer: %p, bufferSize: %zu, num: %"
B_PRIu32 "\n", volume, cookie, buffer, bufferSize, *_num);
IndexDirIterator* iterator = (IndexDirIterator*)cookie;
if (*_num == 0)
return B_BAD_VALUE;
IndexDirIterator previousIterator = *iterator;
// get the next index
Index* index = iterator->Next();
if (index == NULL) {
*_num = 0;
return B_OK;
}
// fill in the entry
if (!set_dirent_name(buffer, bufferSize, index->Name())) {
*iterator = previousIterator;
return B_BUFFER_OVERFLOW;
}
buffer->d_dev = volume->ID();
buffer->d_ino = 0;
*_num = 1;
return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:35,代码来源:kernel_interface.cpp
示例2: packagefs_get_vnode
static status_t
packagefs_get_vnode(fs_volume* fsVolume, ino_t vnid, fs_vnode* fsNode,
int* _type, uint32* _flags, bool reenter)
{
Volume* volume = (Volume*)fsVolume->private_volume;
FUNCTION("volume: %p, vnid: %" B_PRId64 "\n", volume, vnid);
VolumeReadLocker volumeLocker(volume);
Node* node = volume->FindNode(vnid);
if (node == NULL)
return B_ENTRY_NOT_FOUND;
BReference<Node> nodeReference(node);
volumeLocker.Unlock();
NodeWriteLocker nodeLocker(node);
status_t error = node->VFSInit(volume->ID());
if (error != B_OK)
RETURN_ERROR(error);
nodeLocker.Unlock();
fsNode->private_node = nodeReference.Detach();
fsNode->ops = &gPackageFSVnodeOps;
*_type = node->Mode() & S_IFMT;
*_flags = 0;
return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:28,代码来源:kernel_interface.cpp
示例3: packagefs_mount
static status_t
packagefs_mount(fs_volume* fsVolume, const char* device, uint32 flags,
const char* parameters, ino_t* _rootID)
{
FUNCTION("fsVolume: %p, device: \"%s\", flags: %#" B_PRIx32 ", parameters: "
"\"%s\"\n", fsVolume, device, flags, parameters);
// create a Volume object
Volume* volume = new(std::nothrow) Volume(fsVolume);
if (volume == NULL)
RETURN_ERROR(B_NO_MEMORY);
ObjectDeleter<Volume> volumeDeleter(volume);
// Initialize the fs_volume now already, so it is mostly usable in during
// mounting.
fsVolume->private_volume = volumeDeleter.Detach();
fsVolume->ops = &gPackageFSVolumeOps;
status_t error = volume->Mount(parameters);
if (error != B_OK)
return error;
// set return values
*_rootID = volume->RootDirectory()->ID();
return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:27,代码来源:kernel_interface.cpp
示例4: reiserfs_open
// reiserfs_open
static status_t
reiserfs_open(fs_volume *fs, fs_vnode *_node, int openMode, void **cookie)
{
// FUNCTION_START();
Volume *volume = (Volume*)fs->private_volume;
VNode *node = (VNode*)_node->private_node;
FUNCTION(("node: (%Ld: %lu, %lu)\n", node->GetID(), node->GetDirID(),
node->GetObjectID()));
status_t error = B_OK;
// check the open mode
if ((openMode & O_RWMASK) == O_WRONLY || (openMode & O_RWMASK) == O_RDWR
|| (openMode & (O_TRUNC | O_CREAT))) {
error = B_READ_ONLY_DEVICE;
}
// create a StreamReader
if (error == B_OK) {
StreamReader *reader = new(nothrow) StreamReader(volume->GetTree(),
node->GetDirID(), node->GetObjectID());
if (reader) {
error = reader->Suspend();
if (error == B_OK)
*cookie = reader;
else
delete reader;
} else
error = B_NO_MEMORY;
}
RETURN_ERROR(error);
}
开发者ID:luciang,项目名称:haiku,代码行数:30,代码来源:kernel_interface.cpp
示例5: while
// HandleEvent
void
ServerVolume::HandleEvent(VolumeEvent* event)
{
if (event->GetType() == CONNECTION_BROKEN_EVENT) {
// tell all share volumes that they have been disconnected
// init a directory iterator
fLock.Lock();
VirtualDirIterator iterator;
iterator.SetDirectory(fRootNode, true);
// iterate through the directory
const char* name;
Node* node;
while (iterator.GetCurrentEntry(&name, &node)) {
iterator.NextEntry();
Volume* volume = fVolumeManager->GetVolume(node->GetID());
fLock.Unlock();
if (ShareVolume* shareVolume = dynamic_cast<ShareVolume*>(volume))
shareVolume->ConnectionClosed();
if (volume)
volume->PutVolume();
fLock.Lock();
}
// uninit the directory iterator
iterator.SetDirectory(NULL);
// mark ourselves unmounting
SetUnmounting(true);
fLock.Unlock();
}
}
开发者ID:luciang,项目名称:haiku,代码行数:34,代码来源:ServerVolume.cpp
示例6: ext2_get_vnode
static status_t
ext2_get_vnode(fs_volume* _volume, ino_t id, fs_vnode* _node, int* _type,
uint32* _flags, bool reenter)
{
Volume* volume = (Volume*)_volume->private_volume;
if (id < 2 || id > volume->NumInodes()) {
ERROR("invalid inode id %" B_PRIdINO " requested!\n", id);
return B_BAD_VALUE;
}
Inode* inode = new(std::nothrow) Inode(volume, id);
if (inode == NULL)
return B_NO_MEMORY;
status_t status = inode->InitCheck();
if (status != B_OK)
delete inode;
if (status == B_OK) {
_node->private_node = inode;
_node->ops = &gExt2VnodeOps;
*_type = inode->Mode();
*_flags = 0;
} else
ERROR("get_vnode: InitCheck() failed. Error: %s\n", strerror(status));
return status;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:29,代码来源:kernel_interface.cpp
示例7: GetNeighbours
////////////////////////////////////////////////////////////////////////
// GetNeighbours - sreiter
void GetNeighbours(std::vector<Volume*>& vVolsOut, Grid& grid, Volume* v,
int side, bool clearContainer)
{
if(clearContainer)
vVolsOut.clear();
// if VOLOPT_AUTOGENERATE_FACES and FACEOPT_STORE_ASSOCIATED_VOLUMES are
// activated, we may use them to find the connected volume quite fast.
if(grid.option_is_enabled(VOLOPT_AUTOGENERATE_FACES
| FACEOPT_STORE_ASSOCIATED_VOLUMES))
{
Face* f = grid.get_face(v, side);
Grid::AssociatedVolumeIterator iterEnd = grid.associated_volumes_end(f);
for(Grid::AssociatedVolumeIterator iter = grid.associated_volumes_begin(f);
iter != iterEnd; ++iter)
{
if(*iter != v)
vVolsOut.push_back(*iter);
}
return;
}
// we can't assume that associated faces exist.
// we have to find the neighbour by hand.
// mark all vertices of the side
grid.begin_marking();
FaceDescriptor fd;
v->face_desc(side, fd);
uint numFaceVrts = fd.num_vertices();
for(uint i = 0; i < numFaceVrts; ++ i)
grid.mark(fd.vertex(i));
// iterate over associated volumes of the first vertex and count
// the number of marked vertices it contains.
Vertex* vrt = fd.vertex(0);
Grid::AssociatedVolumeIterator iterEnd = grid.associated_volumes_end(vrt);
for(Grid::AssociatedVolumeIterator iter = grid.associated_volumes_begin(vrt);
iter != iterEnd; ++iter)
{
Volume* vol = *iter;
if(vol != v){
size_t count = 0;
uint numVrts = vol->num_vertices();
for(uint i = 0; i < numVrts; ++i){
if(grid.is_marked(vol->vertex(i)))
++count;
}
// if the number of marked vertices in vol matches the
// number of vertices of the specified side, we consider
// the volume to be a neighbout of that side.
if(count == numFaceVrts)
vVolsOut.push_back(vol);
}
}
grid.end_marking();
}
开发者ID:stephanmg,项目名称:ugcore,代码行数:62,代码来源:volume_util.cpp
示例8: checksumfs_read_fs_info
static status_t
checksumfs_read_fs_info(fs_volume* fsVolume, struct fs_info* info)
{
Volume* volume = (Volume*)fsVolume->private_volume;
volume->GetInfo(*info);
return B_OK;
}
开发者ID:mariuz,项目名称:haiku,代码行数:7,代码来源:checksumfs.cpp
示例9: createDiskInfo
// NOTE: We only set the volume in DiskInfo if 'containerPath' is set.
// If volume mode is not specified, Volume::RW will be used (assuming
// 'containerPath' is set).
inline Resource::DiskInfo createDiskInfo(
const Option<std::string>& persistenceId,
const Option<std::string>& containerPath,
const Option<Volume::Mode>& mode = None(),
const Option<std::string>& hostPath = None(),
const Option<Resource::DiskInfo::Source>& source = None())
{
Resource::DiskInfo info;
if (persistenceId.isSome()) {
info.mutable_persistence()->set_id(persistenceId.get());
}
if (containerPath.isSome()) {
Volume volume;
volume.set_container_path(containerPath.get());
volume.set_mode(mode.isSome() ? mode.get() : Volume::RW);
if (hostPath.isSome()) {
volume.set_host_path(hostPath.get());
}
info.mutable_volume()->CopyFrom(volume);
}
if (source.isSome()) {
info.mutable_source()->CopyFrom(source.get());
}
return info;
}
开发者ID:g7z6km,项目名称:mesos,代码行数:34,代码来源:mesos.hpp
示例10: DVRVOLUME_PARAMETER
//! set the bounding volume of the node
void DVRVolume::adjustVolume(Volume &volume)
{
volume.setValid();
volume.setEmpty();
DVRVolumeTexturePtr tex = DVRVOLUME_PARAMETER(this, DVRVolumeTexture);
if (tex != NullFC)
{
const Vec3f & res = tex->getResolution ();
const Vec3f & slice = tex->getSliceThickness();
Vec3f minBB(-0.5f * res[0] * slice[0],
-0.5f * res[1] * slice[1],
-0.5f * res[2] * slice[2]);
Vec3f maxBB(-minBB);
volume.extendBy(minBB);
volume.extendBy(maxBB);
}
else
{
// something wrong with initialization - show boundingbox either
Vec3f minBB(-0.5, -0.5, -0.5);
Vec3f maxBB( 0.5, 0.5, 0.5);
volume.extendBy(minBB);
volume.extendBy(maxBB);
}
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:32,代码来源:OSGDVRVolume.cpp
示例11: ext2_io
static status_t
ext2_io(fs_volume* _volume, fs_vnode* _node, void* _cookie, io_request* request)
{
Volume* volume = (Volume*)_volume->private_volume;
Inode* inode = (Inode*)_node->private_node;
#ifndef EXT2_SHELL
if (io_request_is_write(request) && volume->IsReadOnly()) {
notify_io_request(request, B_READ_ONLY_DEVICE);
return B_READ_ONLY_DEVICE;
}
#endif
if (inode->FileCache() == NULL) {
#ifndef EXT2_SHELL
notify_io_request(request, B_BAD_VALUE);
#endif
return B_BAD_VALUE;
}
// We lock the node here and will unlock it in the "finished" hook.
rw_lock_read_lock(inode->Lock());
return do_iterative_fd_io(volume->Device(), request,
iterative_io_get_vecs_hook, iterative_io_finished_hook, inode);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:26,代码来源:kernel_interface.cpp
示例12: ExportSystemData
bool ExportSystemData(const Volume& volume, const Partition& partition,
const std::string& export_folder)
{
bool success = true;
File::CreateFullPath(export_folder + "/sys/");
success &= ExportHeader(volume, partition, export_folder + "/sys/boot.bin");
success &= ExportBI2Data(volume, partition, export_folder + "/sys/bi2.bin");
success &= ExportApploader(volume, partition, export_folder + "/sys/apploader.img");
success &= ExportDOL(volume, partition, export_folder + "/sys/main.dol");
success &= ExportFST(volume, partition, export_folder + "/sys/fst.bin");
if (volume.GetVolumeType() == Platform::WiiDisc)
{
File::CreateFullPath(export_folder + "/disc/");
success &= ExportWiiUnencryptedHeader(volume, export_folder + "/disc/header.bin");
success &= ExportWiiRegionData(volume, export_folder + "/disc/region.bin");
success &= ExportTicket(volume, partition, export_folder + "/ticket.bin");
success &= ExportTMD(volume, partition, export_folder + "/tmd.bin");
success &= ExportCertificateChain(volume, partition, export_folder + "/cert.bin");
if (volume.IsEncryptedAndHashed())
success &= ExportH3Hashes(volume, partition, export_folder + "/h3.bin");
}
return success;
}
开发者ID:booto,项目名称:dolphin,代码行数:27,代码来源:DiscExtractor.cpp
示例13: loadModelSTL_binary
Model loadModelSTL_binary(const char* filename)
{
Model m;
FILE* f = fopen(filename, "rb");
if (f == NULL) {
ostringstream oss;
oss << "Can't open file " << filename << " for reading";
throw oss.str();
}
char buffer[80];
uint32_t faceCount;
//Skip the header
if (fread(buffer, 80, 1, f) != 1)
{
fclose(f);
return m;
}
//Read the face count
if (fread(&faceCount, sizeof(uint32_t), 1, f) != 1)
{
fclose(f);
return m;
}
//For each face read:
//float(x,y,z) = normal, float(X,Y,Z)*3 = vertexes, uint16_t = flags
m.volumes.push_back(Volume());
Volume* vol = &m.volumes[0];
if(vol == NULL)
{
fclose(f);
return m;
}
for(unsigned int i=0;i<faceCount;i++)
{
if (fread(buffer, sizeof(float) * 3, 1, f) != 1)
{
fclose(f);
return m;
}
float v[9];
if (fread(v, sizeof(float) * 9, 1, f) != 1)
{
fclose(f);
return m;
}
Point3 v0 = Point3(v[0]*1000, v[1]*1000, v[2]*1000);
Point3 v1 = Point3(v[3]*1000, v[4]*1000, v[5]*1000);
Point3 v2 = Point3(v[6]*1000, v[7]*1000, v[8]*1000);
vol->addFace(Face(v0, v1, v2));
if (fread(buffer, sizeof(uint16_t), 1, f) != 1)
{
fclose(f);
return m;
}
}
fclose(f);
return m;
}
开发者ID:DeuxVis,项目名称:Plater,代码行数:60,代码来源:StlFactory.cpp
示例14: ext2_get_file_map
static status_t
ext2_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset,
size_t size, struct file_io_vec* vecs, size_t* _count)
{
TRACE("ext2_get_file_map()\n");
Volume* volume = (Volume*)_volume->private_volume;
Inode* inode = (Inode*)_node->private_node;
size_t index = 0, max = *_count;
while (true) {
fsblock_t block;
uint32 count = 1;
status_t status = inode->FindBlock(offset, block, &count);
if (status != B_OK)
return status;
if (block > volume->NumBlocks()) {
panic("ext2_get_file_map() found block %" B_PRIu64 " for offset %"
B_PRIdOFF "\n", block, offset);
}
off_t blockOffset = block << volume->BlockShift();
uint32 blockLength = volume->BlockSize() * count;
if (index > 0 && (vecs[index - 1].offset
== blockOffset - vecs[index - 1].length
|| (vecs[index - 1].offset == -1 && block == 0))) {
vecs[index - 1].length += blockLength;
} else {
if (index >= max) {
// we're out of file_io_vecs; let's bail out
*_count = index;
return B_BUFFER_OVERFLOW;
}
// 'block' is 0 for sparse blocks
if (block != 0)
vecs[index].offset = blockOffset;
else
vecs[index].offset = -1;
vecs[index].length = blockLength;
index++;
}
offset += blockLength;
if (offset >= inode->Size() || size <= blockLength) {
// We're done!
*_count = index;
TRACE("ext2_get_file_map for inode %" B_PRIdINO "\n", inode->ID());
return B_OK;
}
size -= blockLength;
}
// can never get here
return B_ERROR;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:60,代码来源:kernel_interface.cpp
示例15: ext2_read_attr_dir
static status_t
ext2_read_attr_dir(fs_volume* _volume, fs_vnode* _node,
void* _cookie, struct dirent* dirent, size_t bufferSize,
uint32* _num)
{
Inode* inode = (Inode*)_node->private_node;
int32 index = *(int32 *)_cookie;
Attribute attribute(inode);
TRACE("%s()\n", __FUNCTION__);
size_t length = bufferSize;
status_t status = attribute.Find(index);
if (status == B_ENTRY_NOT_FOUND) {
*_num = 0;
return B_OK;
} else if (status != B_OK)
return status;
status = attribute.GetName(dirent->d_name, &length);
if (status != B_OK)
return B_OK;
Volume* volume = (Volume*)_volume->private_volume;
dirent->d_dev = volume->ID();
dirent->d_ino = inode->ID();
dirent->d_reclen = sizeof(struct dirent) + length;
*_num = 1;
*(int32*)_cookie = index + 1;
return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:32,代码来源:kernel_interface.cpp
示例16: reiserfs_mount
// reiserfs_mount
static status_t
reiserfs_mount(fs_volume *_volume, const char *device, uint32 flags,
const char *parameters, ino_t *rootID)
{
TOUCH(flags); TOUCH(parameters);
FUNCTION_START();
// parameters are ignored for now
status_t error = B_OK;
// allocate and init the volume
Volume *volume = new(nothrow) Volume;
if (!volume)
error = B_NO_MEMORY;
if (error == B_OK)
error = volume->Mount(_volume, device);
// set the results
if (error == B_OK) {
*rootID = volume->GetRootVNode()->GetID();
_volume->private_volume = volume;
_volume->ops = &gReiserFSVolumeOps;
}
// cleanup on failure
if (error != B_OK && volume)
delete volume;
RETURN_ERROR(error);
}
开发者ID:luciang,项目名称:haiku,代码行数:29,代码来源:kernel_interface.cpp
示例17: ext2_mount
static status_t
ext2_mount(fs_volume* _volume, const char* device, uint32 flags,
const char* args, ino_t* _rootID)
{
Volume* volume = new(std::nothrow) Volume(_volume);
if (volume == NULL)
return B_NO_MEMORY;
// TODO: this is a bit hacky: we can't use publish_vnode() to publish
// the root node, or else its file cache cannot be created (we could
// create it later, though). Therefore we're using get_vnode() in Mount(),
// but that requires us to export our volume data before calling it.
_volume->private_volume = volume;
_volume->ops = &gExt2VolumeOps;
status_t status = volume->Mount(device, flags);
if (status != B_OK) {
ERROR("Failed mounting the volume. Error: %s\n", strerror(status));
delete volume;
return status;
}
*_rootID = volume->RootNode()->ID();
return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:25,代码来源:kernel_interface.cpp
示例18: checksumfs_unmount
static status_t
checksumfs_unmount(fs_volume* fsVolume)
{
Volume* volume = (Volume*)fsVolume->private_volume;
volume->Unmount();
return B_OK;
}
开发者ID:mariuz,项目名称:haiku,代码行数:7,代码来源:checksumfs.cpp
示例19: ext2_lookup
static status_t
ext2_lookup(fs_volume* _volume, fs_vnode* _directory, const char* name,
ino_t* _vnodeID)
{
TRACE("ext2_lookup: name address: %p\n", name);
TRACE("ext2_lookup: name: %s\n", name);
Volume* volume = (Volume*)_volume->private_volume;
Inode* directory = (Inode*)_directory->private_node;
// check access permissions
status_t status = directory->CheckPermissions(X_OK);
if (status < B_OK)
return status;
HTree htree(volume, directory);
DirectoryIterator* iterator;
status = htree.Lookup(name, &iterator);
if (status != B_OK)
return status;
ObjectDeleter<DirectoryIterator> iteratorDeleter(iterator);
status = iterator->FindEntry(name, _vnodeID);
if (status != B_OK)
return status;
return get_vnode(volume->FSVolume(), *_vnodeID, NULL);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:29,代码来源:kernel_interface.cpp
示例20: ext2_open
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;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:59,代码来源:kernel_interface.cpp
注:本文中的Volume类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论