示例#1
0
FileMapDisk *
FileMapDisk::FindAnyFileMapDisk(Directory *volume)
{
	TRACE(("FileMapDisk::FindAnyFileMapDisk(%p)\n", volume));
	Node *node;
	status_t error;

	if (!volume)
		return NULL;

	//XXX: check lower/mixed case as well
	Node *dirnode;
	Directory *dir;
	dirnode = volume->Lookup(FMAP_FOLDER_NAME, true);
	if (!dirnode || !S_ISDIR(dirnode->Type()))
		return NULL;
	dir = (Directory *)dirnode;
	node = dir->Lookup(FMAP_IMAGE_NAME, true);
	if (!node)
		return NULL;

	// create a FileMapDisk object
	FileMapDisk *disk = new(nothrow) FileMapDisk;
	if (disk) {
		error = disk->Init(node);
		if (error != B_OK) {
			delete disk;
			disk = NULL;
		}
	}

	return disk;
}
示例#2
0
int main()
{
   Directory d;			// Create and initialize a new directory.

   ShowMenu();				// Display the menu.

   char command;			// menu command entered by user
   do
   {
	command = GetCommand();		// Retrieve a command.
	switch (command)
	{
		case 'I': d.Insert();				break;
		case 'L': d.Lookup();				break;
		case 'R': d.Remove();				break;
		case 'U': d.Update();				break;
		case 'D': d.DisplayDirectory();	break;
		case '?': ShowMenu();				break;
		case 'Q':					break;
	}
   } while (command != 'Q');

   return 0;
}