本文整理汇总了C++中BVolume::Device方法的典型用法代码示例。如果您正苦于以下问题:C++ BVolume::Device方法的具体用法?C++ BVolume::Device怎么用?C++ BVolume::Device使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BVolume
的用法示例。
在下文中一共展示了BVolume::Device方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: next
inline bool QStorageIterator::next()
{
BVolume volume;
if (m_volumeRoster.GetNextVolume(&volume) != B_OK)
return false;
BDirectory directory;
if (volume.GetRootDirectory(&directory) != B_OK)
return false;
const BPath path(&directory);
fs_info fsInfo;
memset(&fsInfo, 0, sizeof(fsInfo));
if (fs_stat_dev(volume.Device(), &fsInfo) != 0)
return false;
m_rootPath = path.Path();
m_fileSystemType = QByteArray(fsInfo.fsh_name);
const QByteArray deviceName(fsInfo.device_name);
m_device = (deviceName.isEmpty() ? QByteArray::number(qint32(volume.Device())) : deviceName);
return true;
}
示例2: GetTrackerResources
void
BTrashWatcher::UpdateTrashIcons()
{
BVolume boot;
if (BVolumeRoster().GetBootVolume(&boot) != B_OK)
return;
BDirectory trashDir;
if (FSGetTrashDir(&trashDir, boot.Device()) == B_OK) {
// pull out the icons for the current trash state from resources and
// apply them onto the trash directory node
size_t largeSize = 0;
size_t smallSize = 0;
const void *largeData = GetTrackerResources()->LoadResource('ICON',
fTrashFull ? kResTrashFullIcon : kResTrashIcon, &largeSize);
const void *smallData = GetTrackerResources()->LoadResource('MICN',
fTrashFull ? kResTrashFullIcon : kResTrashIcon, &smallSize);
if (largeData)
trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0,
largeData, largeSize);
else
TRESPASS();
if (smallData)
trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0,
smallData, smallSize);
else
TRESPASS();
}
}
示例3:
void
AutoMounter::GetSettings(BMessage *_DEVICE_MAP_ONLY(message))
{
#if _INCLUDES_CLASS_DEVICE_MAP
message->AddBool("checkRemovableOnly", fScanParams.removableOrUnknownOnly);
message->AddBool("checkCDs", fScanParams.checkCDROMs);
message->AddBool("checkFloppies", fScanParams.checkFloppies);
message->AddBool("checkOtherRemovables", fScanParams.checkOtherRemovable);
message->AddBool("autoMountRemovableOnly", fAutomountParams.mountRemovableDisksOnly);
message->AddBool("autoMountAll", fAutomountParams.mountAllFS);
message->AddBool("autoMountAllBFS", fAutomountParams.mountBFS);
message->AddBool("autoMountAllHFS", fAutomountParams.mountHFS);
message->AddBool("initialMountAll", fInitialMountAll);
message->AddBool("initialMountAllBFS", fInitialMountAllBFS);
message->AddBool("initialMountRestore", fInitialMountRestore);
message->AddBool("initialMountAllHFS", fInitialMountAllHFS);
message->AddBool("suspended", fSuspended);
// Save mounted volumes so we can optionally mount them on next
// startup
BVolumeRoster volumeRoster;
BVolume volume;
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
fs_info info;
if (fs_stat_dev(volume.Device(), &info) == 0
&& info.flags & (B_FS_IS_REMOVABLE | B_FS_IS_PERSISTENT))
message->AddString(info.device_name, info.volume_name);
}
#endif
}
示例4: while
static char *getMountPoint(const char *devname, char *buf, size_t bufsize)
{
BVolumeRoster mounts;
BVolume vol;
mounts.Rewind();
while (mounts.GetNextVolume(&vol) == B_NO_ERROR)
{
fs_info fsinfo;
fs_stat_dev(vol.Device(), &fsinfo);
if (strcmp(devname, fsinfo.device_name) == 0)
{
BDirectory directory;
BEntry entry;
BPath path;
const char *str;
if ( (vol.GetRootDirectory(&directory) < B_OK) ||
(directory.GetEntry(&entry) < B_OK) ||
(entry.GetPath(&path) < B_OK) ||
( (str = path.Path()) == NULL) )
return NULL;
strncpy(buf, str, bufsize-1);
buf[bufsize-1] = '\0';
return buf;
} /* if */
} /* while */
return NULL;
} /* getMountPoint */
示例5: Visit
/*! \brief Finds a BPartition by BVolume.
*/
status_t
BDiskDeviceRoster::FindPartitionByVolume(const BVolume& volume,
BDiskDevice* device, BPartition** _partition)
{
class FindPartitionVisitor : public BDiskDeviceVisitor {
public:
FindPartitionVisitor(dev_t volume)
:
fVolume(volume)
{
}
virtual bool Visit(BDiskDevice* device)
{
return Visit(device, 0);
}
virtual bool Visit(BPartition* partition, int32 level)
{
BVolume volume;
return partition->GetVolume(&volume) == B_OK
&& volume.Device() == fVolume;
}
private:
dev_t fVolume;
} visitor(volume.Device());
if (VisitEachMountedPartition(&visitor, device, _partition))
return B_OK;
return B_ENTRY_NOT_FOUND;
}
示例6: startModel
bool
BNavMenu::StartBuildingItemList()
{
BEntry entry;
if (fNavDir.device < 0 || entry.SetTo(&fNavDir) != B_OK
|| !entry.Exists())
return false;
fItemList = new BObjectList<BMenuItem>(50);
fIteratingDesktop = false;
BDirectory parent;
status_t status = entry.GetParent(&parent);
// if ref is the root item then build list of volume root dirs
fFlags = uint8((fFlags & ~kVolumesOnly) | (status == B_ENTRY_NOT_FOUND ? kVolumesOnly : 0));
if (fFlags & kVolumesOnly)
return true;
Model startModel(&entry, true);
if (startModel.InitCheck() != B_OK || !startModel.IsContainer())
return false;
if (startModel.IsQuery())
fContainer = new QueryEntryListCollection(&startModel);
else if (FSIsDeskDir(&entry)) {
fIteratingDesktop = true;
fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef());
AddRootItemsIfNeeded();
} else if (FSIsTrashDir(&entry)) {
// the trash window needs to display a union of all the
// trash folders from all the mounted volumes
BVolumeRoster volRoster;
volRoster.Rewind();
BVolume volume;
fContainer = new EntryIteratorList();
while (volRoster.GetNextVolume(&volume) == B_OK) {
if (!volume.IsPersistent())
continue;
BDirectory trashDir;
if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK)
dynamic_cast<EntryIteratorList *>(fContainer)->
AddItem(new DirectoryEntryList(trashDir));
}
} else
fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory *>
(startModel.Node()));
if (fContainer == NULL || fContainer->InitCheck() != B_OK)
return false;
fContainer->Rewind();
return true;
}
示例7: open
// get_volume_info
bool
get_volume_info( BVolume& volume, BString& volumeName, bool& isCDROM, BString& deviceName )
{
bool success = false;
isCDROM = false;
deviceName = "";
volumeName = "";
char name[B_FILE_NAME_LENGTH];
if ( volume.GetName( name ) >= B_OK ) // disk is currently mounted
{
volumeName = name;
dev_t dev = volume.Device();
fs_info info;
if ( fs_stat_dev( dev, &info ) == B_OK )
{
success = true;
deviceName = info.device_name;
if ( volume.IsReadOnly() )
{
int i_dev = open( info.device_name, O_RDONLY );
if ( i_dev >= 0 )
{
device_geometry g;
if ( ioctl( i_dev, B_GET_GEOMETRY, &g, sizeof( g ) ) >= 0 )
isCDROM = ( g.device_type == B_CD );
close( i_dev );
}
}
}
}
return success;
}
示例8:
int
getextmntent_haiku(int* cookie, struct extmnttab *mp, int len)
{
static BLocker extmntent_locker;
extmntent_locker.Lock();
BVolumeRoster roster;
BVolume volume;
int ret = -1;
roster.Rewind();
for (int i = 0; i <= *cookie; i++)
if (roster.GetNextVolume(&volume) != B_NO_ERROR)
return -1;
if (getmntent_haiku(cookie, (struct mnttab*)mp) == 0) {
mp->mnt_major = volume.Device();
mp->mnt_minor = volume.Device();
ret = 0;
}
extmntent_locker.Unlock();
return ret;
}
示例9: while
static char *getMountPoint(const char *devname)
{
BVolumeRoster mounts;
BVolume vol;
mounts.Rewind();
while (mounts.GetNextVolume(&vol) == B_NO_ERROR)
{
fs_info fsinfo;
fs_stat_dev(vol.Device(), &fsinfo);
if (strcmp(devname, fsinfo.device_name) == 0)
{
//char buf[B_FILE_NAME_LENGTH];
BDirectory directory;
BEntry entry;
BPath path;
status_t rc;
rc = vol.GetRootDirectory(&directory);
BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
rc = directory.GetEntry(&entry);
BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
rc = entry.GetPath(&path);
BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
const char *str = path.Path();
BAIL_IF_MACRO(str == NULL, ERR_OS_ERROR, NULL); /* ?! */
char *retval = (char *) allocator.Malloc(strlen(str) + 1);
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
strcpy(retval, str);
return(retval);
} /* if */
} /* while */
return(NULL);
} /* getMountPoint */
示例10: Lookup
status_t
CDDBLookup::Lookup(CDDBServer& server, const char* path, bool dumpOnly,
bool verbose)
{
BVolumeRoster roster;
BVolume volume;
while (roster.GetNextVolume(&volume) == B_OK) {
fs_info info;
if (fs_stat_dev(volume.Device(), &info) != B_OK)
continue;
if (strcmp(path, info.device_name) == 0)
return Lookup(server, volume.Device(), dumpOnly, verbose);
}
return B_ENTRY_NOT_FOUND;
}
示例11:
void
CDDBLookup::LookupAll(CDDBServer& server, bool dumpOnly, bool verbose)
{
BVolumeRoster roster;
BVolume volume;
while (roster.GetNextVolume(&volume) == B_OK) {
Lookup(server, volume.Device(), dumpOnly, verbose);
}
}
示例12: add
void
LiveQuery::_AddQuery(BVolume& volume, const char* predicate)
{
BMessage add(kMsgAddQuery);
add.AddInt32("volume", volume.Device());
add.AddString("predicate", predicate);
PostMessage(&add);
}
示例13: SetUpMimeTyp
status_t TaskFS::SetUpMimeTyp(void)
{
status_t err;
//set the MimeType
BMimeType mime(TASK_MIMETYPE);
//later do better check
bool valid = mime.IsInstalled();
if (!valid) {
mime.Install();
mime.SetShortDescription(B_TRANSLATE_CONTEXT("Tasks",
"Short mimetype description"));
mime.SetLongDescription(B_TRANSLATE_CONTEXT("Tasks",
"Long mimetype description"));
//get the icon from our Ressources
BResources* res = BApplication::AppResources();
if (res != NULL){
size_t size;
const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "TASK_ICON", &size);
if (data!=NULL)
mime.SetIcon(reinterpret_cast<const uint8*>(data), size);
}
mime.SetPreferredApp(APP_SIG);
// add default task fields to meta-mime type
BMessage fields;
for (int32 i = 0; sDefaultAttributes[i].attribute; i++) {
fields.AddString("attr:public_name", sDefaultAttributes[i].name);
fields.AddString("attr:name", sDefaultAttributes[i].attribute);
fields.AddInt32("attr:type", sDefaultAttributes[i].type);
fields.AddString("attr:display_as", sDefaultAttributes[i].displayAs);
fields.AddBool("attr:viewable", sDefaultAttributes[i].isPublic);
fields.AddBool("attr:editable", sDefaultAttributes[i].editable);
fields.AddInt32("attr:width", sDefaultAttributes[i].width);
fields.AddInt32("attr:alignment", B_ALIGN_LEFT);
fields.AddBool("attr:extra", false);
}
mime.SetAttrInfo(&fields);
// create indices on all volumes for the found attributes.
int32 count = 8;
BVolumeRoster volumeRoster;
BVolume volume;
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
for (int32 i = 0; i < count; i++) {
if (sDefaultAttributes[i].isPublic == true)
fs_create_index(volume.Device(), sDefaultAttributes[i].attribute,
sDefaultAttributes[i].type, 0);
}
}
}
else
err = B_OK;
return err;
}
示例14:
status_t
CDDBQuery::_OpenContentFile(const int32 &discID)
{
// Makes sure that the lookup has a valid file to work with for the CD
// content. Returns true if there is an existing file, false if a lookup is
// required.
BFile file;
BString predicate;
predicate << "CD:key == " << discID;
entry_ref ref;
BVolumeRoster roster;
BVolume volume;
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) {
if (volume.IsReadOnly() || !volume.IsPersistent() || !volume.KnowsAttr()
|| !volume.KnowsQuery())
continue;
// make sure the volume we are looking at is indexed right
fs_create_index(volume.Device(), "CD:key", B_INT32_TYPE, 0);
BQuery query;
query.SetVolume(&volume);
query.SetPredicate(predicate.String());
if (query.Fetch() != B_OK)
continue;
if (query.GetNextRef(&ref) == B_OK)
break;
}
status_t status = fCDData.Load(ref);
if (status == B_NO_INIT) {
// We receive this error when the Load() function couldn't load the
// track times This just means that we get it from the SCSI data given
// to us in SetToCD
vector<CDAudioTime> times;
GetTrackTimes(&fSCSIData,times);
for (int32 i = 0; i < fCDData.CountTracks(); i++) {
CDAudioTime *item = fCDData.TrackTimeAt(i);
*item = times[i + 1] - times[i];
}
status = B_OK;
}
return status;
}
示例15:
void
TTracker::InstallIndices()
{
BVolumeRoster roster;
BVolume volume;
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) {
if (volume.IsReadOnly() || !volume.IsPersistent()
|| !volume.KnowsAttr() || !volume.KnowsQuery())
continue;
InstallIndices(volume.Device());
}
}