本文整理汇总了C++中Partition::SetVolumeName方法的典型用法代码示例。如果您正苦于以下问题:C++ Partition::SetVolumeName方法的具体用法?C++ Partition::SetVolumeName怎么用?C++ Partition::SetVolumeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Partition
的用法示例。
在下文中一共展示了Partition::SetVolumeName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: root_entry
//.........这里部分代码省略.........
if (partition != 0) {
WRITELOG(("Found device in device list. Updating state to unmounted."));
partition->SetMountState(kNotMounted);
} else
WRITELOG(("Unmounted device %i was not in device list", device));
} else {
WRITELOG(("ERROR: Could not find unmounted device ID in message"));
PRINT_OBJECT(*message);
}
break;
}
// The name of a mount point has changed
case B_ENTRY_MOVED: {
WRITELOG(("*** Received Mount Point Renamed Notification"));
const char *newName;
if (message->FindString("name", &newName) != B_OK) {
WRITELOG(("ERROR: Couldn't find name field in update message"));
PRINT_OBJECT(*message);
break ;
}
//
// When the node monitor reports a move, it gives the
// parent device and inode that moved. The problem is
// that the inode is the inode of root *in* the filesystem,
// which is generally always the same number for every
// filesystem of a type.
//
// What we'd really like is the device that the moved
// volume is mounted on. Find this by using the
// *new* name and directory, and then stat()ing that to
// find the device.
//
dev_t parentDevice;
if (message->FindInt32("device", &parentDevice) != B_OK) {
WRITELOG(("ERROR: Couldn't find 'device' field in update"
" message"));
PRINT_OBJECT(*message);
break;
}
ino_t toDirectory;
if (message->FindInt64("to directory", &toDirectory)!=B_OK){
WRITELOG(("ERROR: Couldn't find 'to directory' field in update"
"message"));
PRINT_OBJECT(*message);
break;
}
entry_ref root_entry(parentDevice, toDirectory, newName);
BNode entryNode(&root_entry);
if (entryNode.InitCheck() != B_OK) {
WRITELOG(("ERROR: Couldn't create mount point entry node: %s/n",
strerror(entryNode.InitCheck())));
break;
}
node_ref mountPointNode;
if (entryNode.GetNodeRef(&mountPointNode) != B_OK) {
WRITELOG(("ERROR: Couldn't get node ref for new mount point"));
break;
}
WRITELOG(("Attempt to rename device %li to %s", mountPointNode.device,
newName));
Partition *partition = FindPartition(mountPointNode.device);
if (partition != NULL) {
WRITELOG(("Found device, changing name."));
BVolume mountVolume(partition->VolumeDeviceID());
BDirectory mountDir;
mountVolume.GetRootDirectory(&mountDir);
BPath dirPath(&mountDir, 0);
partition->SetMountedAt(dirPath.Path());
partition->SetVolumeName(newName);
break;
}
else
WRITELOG(("ERROR: Device %li does not appear to be present",
mountPointNode.device));
}
}
}
break;
#endif
default:
BLooper::MessageReceived(message);
break;
}
}
示例2: root_entry
//.........这里部分代码省略.........
break;
_MountVolumes(kNoVolumes, fRemovableMode, false, deviceID);
break;
#if 0
case B_NODE_MONITOR:
{
int32 opcode;
if (message->FindInt32("opcode", &opcode) != B_OK)
break;
switch (opcode) {
// The name of a mount point has changed
case B_ENTRY_MOVED: {
WRITELOG(("*** Received Mount Point Renamed Notification"));
const char *newName;
if (message->FindString("name", &newName) != B_OK) {
WRITELOG(("ERROR: Couldn't find name field in update "
"message"));
PRINT_OBJECT(*message);
break ;
}
//
// When the node monitor reports a move, it gives the
// parent device and inode that moved. The problem is
// that the inode is the inode of root *in* the filesystem,
// which is generally always the same number for every
// filesystem of a type.
//
// What we'd really like is the device that the moved
// volume is mounted on. Find this by using the
// *new* name and directory, and then stat()ing that to
// find the device.
//
dev_t parentDevice;
if (message->FindInt32("device", &parentDevice) != B_OK) {
WRITELOG(("ERROR: Couldn't find 'device' field in "
"update message"));
PRINT_OBJECT(*message);
break;
}
ino_t toDirectory;
if (message->FindInt64("to directory", &toDirectory)
!= B_OK) {
WRITELOG(("ERROR: Couldn't find 'to directory' field "
"in update message"));
PRINT_OBJECT(*message);
break;
}
entry_ref root_entry(parentDevice, toDirectory, newName);
BNode entryNode(&root_entry);
if (entryNode.InitCheck() != B_OK) {
WRITELOG(("ERROR: Couldn't create mount point entry "
"node: %s/n", strerror(entryNode.InitCheck())));
break;
}
node_ref mountPointNode;
if (entryNode.GetNodeRef(&mountPointNode) != B_OK) {
WRITELOG(("ERROR: Couldn't get node ref for new mount "
"point"));
break;
}
WRITELOG(("Attempt to rename device %li to %s",
mountPointNode.device, newName));
Partition *partition = FindPartition(mountPointNode.device);
if (partition != NULL) {
WRITELOG(("Found device, changing name."));
BVolume mountVolume(partition->VolumeDeviceID());
BDirectory mountDir;
mountVolume.GetRootDirectory(&mountDir);
BPath dirPath(&mountDir, 0);
partition->SetMountedAt(dirPath.Path());
partition->SetVolumeName(newName);
break;
} else {
WRITELOG(("ERROR: Device %li does not appear to be "
"present", mountPointNode.device));
}
}
}
break;
}
#endif
default:
BLooper::MessageReceived(message);
break;
}
}