本文整理汇总了C++中Volume类的典型用法代码示例。如果您正苦于以下问题:C++ Volume类的具体用法?C++ Volume怎么用?C++ Volume使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Volume类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}