当前位置: 首页>>代码示例>>C++>>正文


C++ BDirectory::SetTo方法代码示例

本文整理汇总了C++中BDirectory::SetTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BDirectory::SetTo方法的具体用法?C++ BDirectory::SetTo怎么用?C++ BDirectory::SetTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BDirectory的用法示例。


在下文中一共展示了BDirectory::SetTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ERROR

/*static*/ status_t
FSUtils::OpenSubDirectory(const BDirectory& baseDirectory,
                          const RelativePath& path, bool create, BDirectory& _directory)
{
    // get a string for the path
    BString pathString = path.ToString();
    if (pathString.IsEmpty())
        RETURN_ERROR(B_NO_MEMORY);

    // If creating is not allowed, just try to open it.
    if (!create)
        RETURN_ERROR(_directory.SetTo(&baseDirectory, pathString));

    // get an absolute path and create the subdirectory
    BPath absolutePath;
    status_t error = absolutePath.SetTo(&baseDirectory, pathString);
    if (error != B_OK) {
        ERROR("Volume::OpenSubDirectory(): failed to get absolute path "
              "for subdirectory \"%s\": %s\n", pathString.String(),
              strerror(error));
        RETURN_ERROR(error);
    }

    error = create_directory(absolutePath.Path(),
                             S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
    if (error != B_OK) {
        ERROR("Volume::OpenSubDirectory(): failed to create "
              "subdirectory \"%s\": %s\n", pathString.String(),
              strerror(error));
        RETURN_ERROR(error);
    }

    RETURN_ERROR(_directory.SetTo(&baseDirectory, pathString));
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:34,代码来源:FSUtils.cpp

示例2: while

void
OpenWindow::CollectDevices(BMenu *menu, BEntry *startEntry)
{
    BDirectory directory;
    if (startEntry != NULL)
        directory.SetTo(startEntry);
    else
        directory.SetTo("/dev/disk");

    BEntry entry;
    while (directory.GetNextEntry(&entry) == B_OK) {
        if (entry.IsDirectory()) {
            CollectDevices(menu, &entry);
            continue;
        }

        entry_ref ref;
        if (entry.GetRef(&ref) != B_OK)
            continue;

        BPath path;
        if (entry.GetPath(&path) != B_OK)
            continue;

        BMessage *message = new BMessage(B_REFS_RECEIVED);
        message->AddRef("refs", &ref);

        menu->AddItem(new BMenuItem(path.Path(), message));
    }
}
开发者ID:simonsouth,项目名称:haiku,代码行数:30,代码来源:OpenWindow.cpp

示例3: if

//---------------------- Private ---------------------------------//
status_t
JoyWin::_AddToList(BListView *list, uint32 command, const char* rootPath,
	BEntry *rootEntry)
{
	BDirectory root;

	if ( rootEntry != NULL )
		root.SetTo( rootEntry );
	else if ( rootPath != NULL )
		root.SetTo( rootPath );
	else
		return B_ERROR;

	BEntry entry;
	while ((root.GetNextEntry(&entry)) > B_ERROR ) {
		if (entry.IsDirectory()) {
			_AddToList(list, command, rootPath, &entry);
		} else {
			BPath path;
			entry.GetPath(&path);
			BString str(path.Path());
			str.RemoveFirst(rootPath);
			list->AddItem(new PortItem(str.String()));
		}
	}
	return B_OK;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:28,代码来源:JoyWin.cpp

示例4: tosave

status_t
ThemeManager::SaveTheme(int32 id, bool excl)
{
	FENTRY;
	status_t err;
	BString name, fname;
	BPath path;
	BDirectory dir;
	BDirectory tdir;
	BFile tfile;
	BMessage names;
	BString location;
	BMessage *theme;
	theme = ThemeAt(id);
	if (!theme)
		return EINVAL;
	err = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
	if (err)	return err;
	path.Append(Z_THEMES_FOLDER_NAME);
	err = dir.SetTo(path.Path());
	if (err)	return err;
	err = ThemeName(id, name);
	if (err)	return err;
	fname = name;
	NormalizeThemeFolderName(fname);

	err = ThemeLocation(id, location);
	if (!err) {
		if (location.FindFirst("/boot/beos") >= 0) {
			PRINT(("trying to save theme '%s' to system dir!\n", name.String()));
			return B_PERMISSION_DENIED;
		}
	}
	path.Append(fname.String());
	err = theme->ReplaceString(Z_THEME_LOCATION, path.Path());
	if (err)
		err = theme->AddString(Z_THEME_LOCATION, path.Path());
	
	if (dir.CreateDirectory(fname.String(), NULL) < B_OK) {
		if (excl)
			return B_FILE_EXISTS;
	}
	err = tdir.SetTo(&dir, fname.String());
	if (err)	return err;
	err = tdir.CreateFile(Z_THEME_FILE_NAME, &tfile);
	if (err)	return err;
	
	BMessage tosave(*theme);
	err = tosave.RemoveName(Z_THEME_LOCATION);
	err = GetNames(names);
	
	err = DumpMessageToStream(&tosave, tfile, 0, &names);
	if (err)	return err;
	return B_OK;
}
开发者ID:mmanley,项目名称:Antares,代码行数:55,代码来源:ThemeManager.cpp

示例5: TaskToFile

status_t TaskFS::TaskToFile(Task *theTask, bool overwrite)
{
	BFile		taskFile;
	BEntry		entry;
	status_t	err;
	TaskList	*tskLst	= theTask->GetTaskList();
	
	BDirectory	dir		= BDirectory();

	bool	completed	= theTask->IsCompleted();
	uint32	priority	= theTask->Priority();
	time_t	due			= theTask->DueTime();


	//first find directory.. then create files in this directory
	if (tskLst!=NULL)
		dir.SetTo(&tasksDir,tskLst->Name());
	else
		dir.SetTo(&tasksDir,".");

	
	//first check if the File already exists..
	//if not and overwrite is on check the ids..
	// and search for the correspondending file...

	if (dir.FindEntry(theTask->Title(),&entry) == B_OK) {
		taskFile.SetTo((const BEntry*)&entry,B_READ_WRITE);
		err = B_OK;
	} 
	else {
		entry_ref *ref= FileForId(theTask);
		if (ref==NULL){
			dir.CreateFile(theTask->Title(),&taskFile,overwrite);
			dir.FindEntry(theTask->Title(),&entry);
		}
		else {
			entry.SetTo(ref);
			taskFile.SetTo((const BEntry*)ref,B_READ_WRITE);
		}
	}
	if (taskFile.InitCheck() == B_OK){
		taskFile.WriteAttr("META:completed",B_BOOL_TYPE, 0, &completed, sizeof(completed));
		entry.Rename(theTask->Title());
		taskFile.WriteAttrString("META:tasks",new BString(theTask->GetTaskList()->ID()));
		taskFile.WriteAttrString("META:notes",new BString(theTask->Notes()));
		taskFile.WriteAttr("META:priority", B_UINT32_TYPE, 0, &priority, sizeof(priority));
		taskFile.WriteAttr("META:due", B_TIME_TYPE, 0, &due, sizeof(due));
		taskFile.WriteAttrString("META:task_id",  new BString(theTask->ID()));
		taskFile.WriteAttrString("META:task_url",new BString(theTask->URL()));
	}
	else
		err=B_ERROR;
	return err; 
}
开发者ID:Paradoxianer,项目名称:Tasks,代码行数:54,代码来源:TaskFS.cpp

示例6:

status_t 
ZKWindow::MakeSettingsFolder	(void)
{
	PRINT(("ZKWindow::MakeSettingsFolder()\n"));

	status_t	status;
	BPath		path;
	if ((status = find_directory(B_USER_SETTINGS_DIRECTORY, & path)) != B_OK)
		return status;
	
	BEntry 		entry	(path.Path());

	// settings
	if (entry.Exists()	==	false	||	entry.IsDirectory()	==	false)	
		return B_ERROR;
	
	BDirectory	mother	(path.Path());
	BDirectory	baby;
	
	// Kirilla
	path.SetTo(path.Path(), "Kirilla");
	entry.SetTo(path.Path());
	if (! entry.Exists())
	{
		status	=	mother.CreateDirectory("Kirilla", & baby);
		if (status != B_OK && status != B_FILE_EXISTS)				return status;
	}
	else 
		if (! entry.IsDirectory())
			return B_FILE_EXISTS;
	
	if ((status = mother.SetTo(path.Path())) != B_OK)			return status;

	// ZooKeeper
	path.SetTo(path.Path(), "ZooKeeper");
	entry.SetTo(path.Path());
	if (! entry.Exists())
	{
		status	=	mother.CreateDirectory("ZooKeeper", & baby);
		if (status != B_OK && status != B_FILE_EXISTS)				return status;
	}
	else 
		if (! entry.IsDirectory())
			return B_FILE_EXISTS;
	
	if ((status = mother.SetTo(path.Path())) != B_OK)			return status;

	entry.SetTo(path.Path());
	if (entry.Exists()	&&	entry.IsDirectory())	return B_OK;
	else											return B_ERROR;
}
开发者ID:HaikuArchives,项目名称:ZooKeeper,代码行数:51,代码来源:ZKWindow.cpp

示例7: target

void
PersonWindow::SaveAs()
{
	char name[B_FILE_NAME_LENGTH];
	_GetDefaultFileName(name);

	if (fPanel == NULL) {
		BMessenger target(this);
		fPanel = new BFilePanel(B_SAVE_PANEL, &target);

		BPath path;
		find_directory(B_USER_DIRECTORY, &path, true);

		BDirectory dir;
		dir.SetTo(path.Path());

		BEntry entry;
		if (dir.FindEntry("people", &entry) == B_OK
			|| (dir.CreateDirectory("people", &dir) == B_OK
					&& dir.GetEntry(&entry) == B_OK)) {
			fPanel->SetPanelDirectory(&entry);
		}
	}

	if (fPanel->Window()->Lock()) {
		fPanel->SetSaveText(name);
		if (fPanel->Window()->IsHidden())
			fPanel->Window()->Show();
		else
			fPanel->Window()->Activate();
		fPanel->Window()->Unlock();
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:33,代码来源:PersonWindow.cpp

示例8: BMenu

/*!	Adds a menu populated with the keyboard layouts found in the passed
	in directory to the passed in menu. Each subdirectory in the passed
	in directory is added as a submenu recursively.
*/
void
KeymapWindow::_AddKeyboardLayoutMenu(BMenu* menu, BDirectory directory)
{
	entry_ref ref;

	while (directory.GetNextRef(&ref) == B_OK) {
		if (menu->FindItem(ref.name) != NULL)
			continue;

		BDirectory subdirectory;
		subdirectory.SetTo(&ref);
		if (subdirectory.InitCheck() == B_OK) {
			BMenu* submenu = new BMenu(B_TRANSLATE_NOCOLLECT(ref.name));

			_AddKeyboardLayoutMenu(submenu, subdirectory);
			menu->AddItem(submenu);
		} else {
			BMessage* message = new BMessage(kChangeKeyboardLayout);

			message->AddRef("ref", &ref);
			menu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(ref.name),
				message));
		}
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:29,代码来源:KeymapWindow.cpp

示例9:

bool
AddOnManager::_FindEncoder(const media_format& format, const BPath& path,
	entry_ref* _encoderRef)
{
	node_ref nref;
	BDirectory directory;
	if (directory.SetTo(path.Path()) != B_OK
		|| directory.GetNodeRef(&nref) != B_OK) {
		return false;
	}

	encoder_info* info;
	for (fEncoderList.Rewind(); fEncoderList.GetNext(&info);) {
		if (info->ref.directory != nref.node)
			continue;

		// check if the encoder matches the supplied format
		if (info->outputFormat.Matches(&format)) {
			*_encoderRef = info->ref;
			return true;
		}
		continue;
	}
	return false;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:25,代码来源:AddOnManager.cpp

示例10: directoriesDeleter

void
AddOnManager::RegisterAddOns()
{
	// Check if add-ons are already registered.
	if (!fReaderList.IsEmpty() || !fWriterList.IsEmpty()
		|| !fDecoderList.IsEmpty() || !fEncoderList.IsEmpty()) {
		return;
	}

	char** directories = NULL;
	size_t directoryCount = 0;

	if (find_paths_etc(get_architecture(), B_FIND_PATH_ADD_ONS_DIRECTORY,
			"media/plugins", B_FIND_PATH_EXISTING_ONLY, &directories,
			&directoryCount) != B_OK) {
		return;
	}

	MemoryDeleter directoriesDeleter(directories);

	BPath path;
	for (uint i = 0; i < directoryCount; i++) {
		BDirectory directory;
		if (directory.SetTo(directories[i]) == B_OK) {
			entry_ref ref;
			while(directory.GetNextRef(&ref) == B_OK)
				_RegisterAddOn(ref);
		}
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:30,代码来源:AddOnManager.cpp

示例11: EvaluateRef

status_t TElementsSorter::EvaluateRef(entry_ref &ref)
{
	struct stat st;
	BEntry entry;

	// Can we create a BEntry?
	if (entry.SetTo(&ref, false) != B_OK)
		return B_ERROR;

	// Can we get a BStatable?
	if (entry.GetStat(&st) != B_OK)
		return B_ERROR;

	// Is it a SymLink?
	if (S_ISLNK(st.st_mode))
		return HandleLink(ref, st);
	// How about a File?
	else if (S_ISREG(st.st_mode))
		return HandleFile(ref, st);
	// A Directory?
	else if (S_ISDIR(st.st_mode)) {
		BDirectory dir;
		if (dir.SetTo(&ref) != B_OK)
			return B_ERROR;

		if (dir.IsRootDirectory())
			return HandleVolume(ref, st, dir);
		else
			return HandleDirectory(ref, st, dir);
	}

	// No luck
	return B_ERROR;
}
开发者ID:Barrett17,项目名称:UltraDV,代码行数:34,代码来源:TElementsSorter.cpp

示例12:

bool
AddOnManager::_FindDecoder(const media_format& format, const BPath& path,
	xfer_entry_ref* _decoderRef)
{
	node_ref nref;
	BDirectory directory;
	if (directory.SetTo(path.Path()) != B_OK
		|| directory.GetNodeRef(&nref) != B_OK) {
		return false;
	}

	decoder_info* info;
	for (fDecoderList.Rewind(); fDecoderList.GetNext(&info);) {
		if (info->ref.directory != nref.node)
			continue;

		media_format* decoderFormat;
		for (info->formats.Rewind(); info->formats.GetNext(&decoderFormat);) {
			// check if the decoder matches the supplied format
			if (!decoderFormat->Matches(&format))
				continue;

			printf("AddOnManager::GetDecoderForFormat: found decoder %s/%s "
				"for encoding %" B_PRIu32 "\n", path.Path(), info->ref.name,
				decoderFormat->Encoding());

			*_decoderRef = info->ref;
			return true;
		}
	}
	return false;
}
开发者ID:naveedasmat,项目名称:haiku,代码行数:32,代码来源:AddOnManager.cpp

示例13: if

void
ModuleManager::_FindModules(BDirectory &dir, const char *moduleDir,
	const char *suffix, module_name_list *list)
{
	BEntry entry;
	while (dir.GetNextEntry(&entry) == B_OK) {
		if (entry.IsFile()) {
			ModuleAddOn addon;
			BPath path;
			if (entry.GetPath(&path) == B_OK
				&& addon.Load(path.Path(), moduleDir) == B_OK) {
				module_info **infos = addon.ModuleInfos();
				for (int32 i = 0; infos[i]; i++) {
					if (infos[i]->name
						&& _MatchSuffix(infos[i]->name, suffix))
						list->names.insert(infos[i]->name);
				}
			}
		} else if (entry.IsDirectory()) {
			BDirectory subdir;
			if (subdir.SetTo(&entry) == B_OK)
				_FindModules(subdir, moduleDir, suffix, list);
		}
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:25,代码来源:module.cpp

示例14: SetDefaults

//! Sets the cursors to the defaults and saves them to CURSOR_SETTINGS_DIR/"d
void CursorManager::SetDefaults(void)
{
	Lock();
	CursorSet cs("Default");
	cs.AddCursor(B_CURSOR_DEFAULT,default_cursor_data);
	cs.AddCursor(B_CURSOR_TEXT,default_text_data);
	cs.AddCursor(B_CURSOR_MOVE,default_move_data);
	cs.AddCursor(B_CURSOR_DRAG,default_drag_data);
	cs.AddCursor(B_CURSOR_RESIZE,default_resize_data);
	cs.AddCursor(B_CURSOR_RESIZE_NWSE,default_resize_nwse_data);
	cs.AddCursor(B_CURSOR_RESIZE_NESW,default_resize_nesw_data);
	cs.AddCursor(B_CURSOR_RESIZE_NS,default_resize_ns_data);
	cs.AddCursor(B_CURSOR_RESIZE_EW,default_resize_ew_data);

	BDirectory dir;
	if(dir.SetTo(CURSOR_SET_DIR)==B_ENTRY_NOT_FOUND)
		create_directory(CURSOR_SET_DIR,0777);
	
	BString string(CURSOR_SET_DIR);
	string+="Default";
	cs.Save(string.String(),B_CREATE_FILE | B_FAIL_IF_EXISTS);
	
	SetCursorSet(string.String());
	Unlock();
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:26,代码来源:CursorManager.cpp

示例15: CurrentMessage

void
FileTypes::ArgvReceived(int32 argc, char **argv)
{
	BMessage *message = CurrentMessage();

	BDirectory currentDirectory;
	if (message)
		currentDirectory.SetTo(message->FindString("cwd"));

	BMessage refs;

	for (int i = 1 ; i < argc ; i++) {
		BPath path;
		if (argv[i][0] == '/')
			path.SetTo(argv[i]);
		else
			path.SetTo(&currentDirectory, argv[i]);

		status_t status;
		entry_ref ref;
		BEntry entry;

		if ((status = entry.SetTo(path.Path(), false)) != B_OK
			|| (status = entry.GetRef(&ref)) != B_OK) {
			fprintf(stderr, "Could not open file \"%s\": %s\n",
				path.Path(), strerror(status));
			continue;
		}

		refs.AddRef("refs", &ref);
	}

	RefsReceived(&refs);
}
开发者ID:mariuz,项目名称:haiku,代码行数:34,代码来源:FileTypes.cpp


注:本文中的BDirectory::SetTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。