Esempio n. 1
0
void
IndexServer::AddVolume(const BVolume& volume)
{
	// ignore volumes like / or /dev
	if (volume.Capacity() == 0)
		return;
	
	// check if volume is already in our list
	for (int i = 0; i < fVolumeWatcherList.CountItems(); i++) {
		VolumeWatcher* current = fVolumeWatcherList.ItemAt(i);
		if (current->Volume() == volume)
			return;
	}

	char name[256];
	volume.GetName(name);
	STRACE("IndexServer::AddVolume %s\n", name);

	VolumeWatcher* watcher = new VolumeWatcher(volume);
/*	if (!watcher->Enabled()) {
		delete watcher;
		return;
	}*/
	fVolumeWatcherList.AddItem(watcher);
	_SetupVolumeWatcher(watcher);
	watcher->StartWatching();
}
void PanelView::ReadDisks(void)
////////////////////////////////////////////////////////////////////////
{
	char drivename[256];
	char drivepath[256];

//	SetMousePointer(CR_HOURGLASS);
	MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS);

	CustomListItem *item;

	item = new CustomListItem("..",m_Path.String(),FT_DISKBACK, 0);
	item->AddIcon(m_ParentIcon);
	m_CustomListView->AddItem(item);
	item->SetHeight(15.0f);

	// Collect available volumes...
	BVolumeRoster *vr = new BVolumeRoster();
	if (vr)
	{
		BVolume v;
	
		while (vr->GetNextVolume(&v)==B_NO_ERROR)
		{
			if (v.GetName(drivename)==B_NO_ERROR)
			{
				if (strlen(drivename)>0)
				{
					BDirectory dir;
					BEntry entry;
					BPath path;
					v.GetRootDirectory(&dir);
					dir.GetEntry(&entry);
					entry.GetPath(&path);
					sprintf(drivepath,"%s",path.Path());
					item = new CustomListItem(drivename,drivepath,FT_DISKITEM,v.FreeBytes(),v.Capacity(),v.Device());
					m_CustomListView->AddItem(item);
					if (m_Setting_ShowIcons)
					{
						if (!item->GetIcon(&v))
							item->AddIcon(m_UnknownIcon);
						item->SetHeight(15.0f);
					}
				}
			}
		}

		delete vr;
	}

	m_CustomListView->DoSortList();

	m_CustomListView->Select(0,false);
//	SetMousePointer(CR_DEFAULT);
	MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT);
}
Esempio n. 3
0
/*	isVolume
*	checks if selected file is a volume
*	if yes, returns true
*/	
bool
ProjectTypeSelector::isVolume()
{
	BString *SelectedFile = (BString*)FileList->FirstItem();
	BString SelectedFileTMP;
	BVolumeRoster objVolumeRoster;
	objVolumeRoster.Rewind();
	BVolume objVolume;
	char chVolumeName[B_FILE_NAME_LENGTH];
	
	SelectedFile->CopyInto(SelectedFileTMP, 0, (int)SelectedFile->Length());	
	SelectedFileTMP.RemoveAll("/");
	while(objVolumeRoster.GetNextVolume(&objVolume) != B_BAD_VALUE) {
		objVolume.GetName(chVolumeName);
		
		if(SelectedFileTMP.Compare(chVolumeName) == 0 && objVolume.IsReadOnly()) {
			fSizeOfFiles = objVolume.Capacity();
			return true;
		}
	}
	
	return false;
}
Esempio n. 4
0
status_t ExtractQueryVolumes(BNode *node, vollist *volumes) {
	int32 length = 0;
	char *attr = ReadAttribute(*node, kTrackerQueryVolume, &length);
	BVolumeRoster roster;

	if (attr == NULL) {
		roster.Rewind();
		BVolume vol;
		
		while (roster.GetNextVolume(&vol) == B_NO_ERROR) {
			if ((vol.IsPersistent() == true) && (vol.KnowsQuery() == true)) {
				volumes->push_back(vol);
			};
		};
	} else {
		BMessage msg;
		msg.Unflatten(attr);

//		!*YOINK*!d from that project... with the funny little doggie as a logo...
//		OpenTracker, that's it!
			
		time_t created;
		off_t capacity;
		
		for (int32 index = 0; msg.FindInt32("creationDate", index, &created) == B_OK;
			index++) {
			
			if ((msg.FindInt32("creationDate", index, &created) != B_OK)
				|| (msg.FindInt64("capacity", index, &capacity) != B_OK))
				return B_ERROR;
		
			BVolume volume;
			BString deviceName = "";
			BString volumeName = "";
			BString fshName = "";
		
			if (msg.FindString("deviceName", &deviceName) == B_OK
				&& msg.FindString("volumeName", &volumeName) == B_OK
				&& msg.FindString("fshName", &fshName) == B_OK) {
				// New style volume identifiers: We have a couple of characteristics,
				// and compute a score from them. The volume with the greatest score
				// (if over a certain threshold) is the one we're looking for. We
				// pick the first volume, in case there is more than one with the
				// same score.
				int foundScore = -1;
				roster.Rewind();
				
				char name[B_FILE_NAME_LENGTH];
				
				while (roster.GetNextVolume(&volume) == B_OK) {
					if (volume.IsPersistent() && volume.KnowsQuery()) {
						// get creation time and fs_info
						BDirectory root;
						volume.GetRootDirectory(&root);
						time_t cmpCreated;
						fs_info info;
						if (root.GetCreationTime(&cmpCreated) == B_OK
							&& fs_stat_dev(volume.Device(), &info) == 0) {
							// compute the score
							int score = 0;
		
							// creation time
							if (created == cmpCreated)
								score += 5;
							// capacity
							if (capacity == volume.Capacity())
								score += 4;
							// device name
							if (deviceName == info.device_name)
								score += 3;
							// volume name
							if (volumeName == info.volume_name)
								score += 2;
							// fsh name
							if (fshName == info.fsh_name)
								score += 1;
		
							// check score
							if (score >= 9 && score > foundScore) {
								volume.GetName(name);
								volumes->push_back(volume);
							}
						}
					}
				}
			} else {
				// Old style volume identifiers: We have only creation time and
				// capacity. Both must match.
				roster.Rewind();
				while (roster.GetNextVolume(&volume) == B_OK)
					if (volume.IsPersistent() && volume.KnowsQuery()) {
						BDirectory root;
						volume.GetRootDirectory(&root);
						time_t cmpCreated;
						root.GetCreationTime(&cmpCreated);
						if (created == cmpCreated && capacity == volume.Capacity()) {
							volumes->push_back(volume);
						}
					}
			}
		};
	};

	return B_OK;	
};