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


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

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


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

示例1: appDir

void
EnsureTemplates(void)
{
	// Because creating a new project depends on the existence of the Templates folder,
	// make sure that we have some (very) basic templates to work with if the folder
	// has been deleted.
	DPath templatePath = gAppPath.GetFolder();
	templatePath << "Templates";
	
	bool missing = false;
	BDirectory tempDir;
	if (!BEntry(templatePath.GetFullPath()).Exists())
	{
		BDirectory appDir(gAppPath.GetFolder());
		appDir.CreateDirectory("Templates", &tempDir);
		missing = true;
	}
	else
	{
		tempDir.SetTo(templatePath.GetFullPath());
		if (tempDir.CountEntries() == 0)
			missing = true;
	}
	
	if (missing)
	{
		BDirectory dir;
		tempDir.CreateDirectory("Empty Application", &dir);
		tempDir.CreateDirectory("Kernel Driver", &dir);
		tempDir.CreateDirectory("Shared Library or Addon", &dir);
		tempDir.CreateDirectory("Static Library", &dir);
		
		DPath filePath;
		TextFile file;
		
		filePath = templatePath;
		filePath << "Empty Application/TEMPLATEINFO";
		file.SetTo(filePath.GetFullPath(), B_CREATE_FILE | B_READ_WRITE);
		file.WriteString("TYPE=Application\nLIB=B_BEOS_LIB_DIRECTORY/libsupc++.so\n");
		
		filePath = templatePath;
		filePath << "Kernel Driver/TEMPLATEINFO";
		file.SetTo(filePath.GetFullPath(), B_CREATE_FILE | B_READ_WRITE);
		file.WriteString("TYPE=Driver\n");
		
		filePath = templatePath;
		filePath << "Shared Library or Addon/TEMPLATEINFO";
		file.SetTo(filePath.GetFullPath(), B_CREATE_FILE | B_READ_WRITE);
		file.WriteString("TYPE=Shared\n");
		
		filePath = templatePath;
		filePath << "Static Library/TEMPLATEINFO";
		file.SetTo(filePath.GetFullPath(), B_CREATE_FILE | B_READ_WRITE);
		file.WriteString("TYPE=Static\n");
		
		file.Unset();
	}
}
开发者ID:jscipione,项目名称:Paladin,代码行数:58,代码来源:Globals.cpp

示例2:

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

示例3: LegacyBootMenu

BootManagerController::BootManagerController()
	:
	fBootDrive(NULL),
	fBootMenu(NULL)
{
	// set defaults
	fSettings.AddBool("install", true);
	fSettings.AddInt32("defaultPartition", 0);
	fSettings.AddInt32("timeout", -1);

	BPath path;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
		path.Append("bootman/MBR");
		fSettings.AddString("file", path.Path());
		// create directory
		BPath parent;
		if (path.GetParent(&parent) == B_OK) {
			BDirectory directory;
			directory.CreateDirectory(parent.Path(), NULL);
		}
	} else {
		fSettings.AddString("file", "");
	}

	// That's the only boot menu we support at the moment.
	fBootMenus.AddItem(new LegacyBootMenu());
}
开发者ID:DonCN,项目名称:haiku,代码行数:27,代码来源:BootManagerController.cpp

示例4: BDirectory

status_t
MSNP::Init(CayaProtocolMessengerInterface* msgr)
{
	fServerMsgr = msgr;
	fLogged = false;

	fClientID = 0;
	fClientID += MSN::MSNC7;
	fClientID += MSN::MSNC6;
	fClientID += MSN::MSNC5;
	fClientID += MSN::MSNC4;
	fClientID += MSN::MSNC3;
	fClientID += MSN::MSNC2;
	fClientID += MSN::MSNC1;
	fClientID += MSN::SupportWinks;
	fClientID += MSN::VoiceClips;
	fClientID += MSN::InkGifSupport;
	fClientID += MSN::SIPInvitations;
	fClientID += MSN::SupportMultiPacketMessaging;

	fID = 963396;

	BPath path;
	status_t ret = find_directory(B_USER_CONFIG_DIRECTORY, &path);
	if (ret != B_OK)
		return ret;

	BDirectory cacheDir = BDirectory(path.Path());
	path.Append("settings/Caya/Cache/msn/");
	cacheDir.CreateDirectory(path.Path(), NULL);

	fCachePath = path;

	return B_OK;
}
开发者ID:ModeenF,项目名称:Caya,代码行数:35,代码来源:MSN.cpp

示例5: 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

示例6: 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

示例7:

status_t
GetSettingsDir(BDirectory &dir, BPath &path)
{
	//BPath path;
	status_t err;
	// TODO: build list from text files
	err = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
	if (err < B_OK)
		return err;
	dir.SetTo(path.Path());
	if (!dir.Contains("pe"))
		dir.CreateDirectory("pe", NULL);
	path.Append("pe");
	dir.SetTo(path.Path());
	if (!dir.Contains("HeaderTemplates"))
		dir.CreateDirectory("HeaderTemplates", NULL);
	path.Append("HeaderTemplates");
	dir.SetTo(path.Path());
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:Pe,代码行数:20,代码来源:HeaderHeader.cpp

示例8: GetInstallationLocationInfo

status_t
BDaemonClient::CreateTransaction(BPackageInstallationLocation location,
	BActivationTransaction& _transaction, BDirectory& _transactionDirectory)
{
	// get an info for the location
	BInstallationLocationInfo info;
	status_t error = GetInstallationLocationInfo(location, info);
	if (error != B_OK)
		return error;

	// open admin directory
	entry_ref entryRef;
	entryRef.device = info.PackagesDirectoryRef().device;
	entryRef.directory = info.PackagesDirectoryRef().node;
	error = entryRef.set_name(PACKAGES_DIRECTORY_ADMIN_DIRECTORY);
	if (error != B_OK)
		return error;
	
	BDirectory adminDirectory;
	error = adminDirectory.SetTo(&entryRef);
	if (error != B_OK)
		return error;

	// create a transaction directory
	int uniqueId = 1;
	BString directoryName;
	for (;; uniqueId++) {
		directoryName.SetToFormat("transaction-%d", uniqueId);
		if (directoryName.IsEmpty())
			return B_NO_MEMORY;

		error = adminDirectory.CreateDirectory(directoryName,
			&_transactionDirectory);
		if (error == B_OK)
			break;
		if (error != B_FILE_EXISTS)
			return error;
	}

	// init the transaction
	error = _transaction.SetTo(location, info.ChangeCount(), directoryName);
	if (error != B_OK) {
		BEntry entry;
		_transactionDirectory.GetEntry(&entry);
		_transactionDirectory.Unset();
		if (entry.InitCheck() == B_OK)
			entry.Remove();
		return error;
	}

	return B_OK;
}
开发者ID:naveedasmat,项目名称:haiku,代码行数:52,代码来源:DaemonClient.cpp

示例9: themepath

status_t
ThemeManager::LoadThemes()
{
	FENTRY;
	int dirwhich;
	BPath path;
	BDirectory dir;
	entry_ref ref;
	status_t err;
	
	for (dirwhich = 0; dirwhich < 2; dirwhich++) {
		if (!dirwhich)	/* find system settings dir */
			err = find_directory(B_BEOS_ETC_DIRECTORY, &path);
		else			/* find user settings dir */
			err = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
		if (err)	return err;
		
		err = dir.SetTo(path.Path());
		if (err)	return err;
		BEntry ent;
		if (dir.FindEntry(Z_THEMES_FOLDER_NAME, &ent) < B_OK) {
			dir.CreateDirectory(Z_THEMES_FOLDER_NAME, NULL);
		}
		
		path.Append(Z_THEMES_FOLDER_NAME);
		
		err = dir.SetTo(path.Path());
		if (err)	return err;
		
		err = dir.Rewind();
		if (err)	return err;
		
		while ((err = dir.GetNextRef(&ref)) == B_OK) {
			BPath themepath(&ref);
			BDirectory tdir(themepath.Path());
			err = tdir.InitCheck();
			if (err) /* not a dir */
				continue;
			err = LoadTheme(themepath.Path());
		}
	}
	return B_OK;
}
开发者ID:mmanley,项目名称:Antares,代码行数:43,代码来源:ThemeManager.cpp

示例10:

int32_t
PDirectoryCreateDirectory(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PDirectory *parent = static_cast<PDirectory*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BDirectory *backend = (BDirectory*)parent->GetBackend();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	
	BString path;
	if (args->FindString("path", &path) != B_OK)
		return B_ERROR;
	
	BDirectory newDir;
	status_t status = backend->CreateDirectory(path.String(), &newDir);
	
	outArgs->MakeEmpty();
	
	if (status == B_OK)
	{
		BEntry entry;
		status = newDir.GetEntry(&entry);
		if (status == B_OK)
		{
			BPath dirPath;
			status = entry.GetPath(&dirPath);
			outArgs->AddString("path", dirPath.Path());
		}
	}
	
	outArgs->AddInt32("status", status);
	
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:39,代码来源:PDirectory.cpp

示例11: target

void
PersonWindow::SaveAs(int32 format)
{
	if (format == 0)
		format = B_PERSON_FORMAT;

	char name[B_FILE_NAME_LENGTH];
	_GetDefaultFileName(name);

	if (fPanel == NULL) {
		BPath path;
		BMessenger target(this);
		BMessage msg(B_SAVE_REQUESTED);
		msg.AddInt32("format", format);
		fPanel = new BFilePanel(B_SAVE_PANEL, &target, NULL, 0, true, &msg);
		

		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:mmadia,项目名称:Haiku-services-branch,代码行数:39,代码来源:PersonWindow.cpp

示例12: BGroupLayout

NotificationWindow::NotificationWindow()
	:
	BWindow(BRect(0, 0, -1, -1), B_TRANSLATE_MARK("Notification"),
		B_BORDERED_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_AVOID_FRONT
		| B_AVOID_FOCUS | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE
		| B_NOT_RESIZABLE | B_NOT_MOVABLE | B_AUTO_UPDATE_SIZE_LIMITS,
		B_ALL_WORKSPACES),
	fShouldRun(true)
{
	status_t result = find_directory(B_USER_CACHE_DIRECTORY, &fCachePath);
	fCachePath.Append("Notifications");
	BDirectory cacheDir;
	result = cacheDir.SetTo(fCachePath.Path());
	if (result == B_ENTRY_NOT_FOUND)
		cacheDir.CreateDirectory(fCachePath.Path(), NULL);

	SetLayout(new BGroupLayout(B_VERTICAL, 0));

	_LoadSettings(true);

	// Start the message loop
	Hide();
	Show();
}
开发者ID:looncraz,项目名称:haiku,代码行数:24,代码来源:NotificationWindow.cpp

示例13: dirEntry

BFile*
MilkySettingsApplication::_OpenSettingsFile(uint32 openMode)
{
    BPath path;
    find_directory(B_USER_SETTINGS_DIRECTORY, &path);
    path.Append("MilkyTracker");

    BEntry dirEntry(path.Path());
    if (!dirEntry.Exists()) {
        // MilkyTracker settings dir doesn't exist, create it
        BDirectory temp;
        temp.CreateDirectory(path.Path(), NULL);
    }

    path.Append("platform_settings");
    BFile* file = new BFile(path.Path(), openMode);

    if (file->InitCheck() != B_OK) {
        delete file;
        return NULL;
    }

    return file;
}
开发者ID:FyiurAmron,项目名称:MilkyTracker,代码行数:24,代码来源:MilkySettingsApplication.cpp

示例14: CreateFolder

void SNewFolderWindow::CreateFolder()
{
	char newPath[B_PATH_NAME_LENGTH];

	BString text(iNameTextControl->Text());
	if(text.Compare(".")==0 || text.Compare("..")==0)
	{
		BAlert *alert=new BAlert("Error", "The names '.' and '..' refer to"
		" the current folder and its parent, respectively. Please choose"
		" another name.", "OK");
		alert->Go();
		return;
	}
	if(text.CountChars()==0)
		return;
		
	strcpy(newPath, iParentFile->PathDesc());
	strcat(newPath, "/");
	strcat(newPath, iNameTextControl->Text());

	BDirectory directory;
	status_t rc;
	
	rc=directory.CreateDirectory(newPath, 0);
	
	if(rc!=B_OK)
	{
		char errMsg[80];
		switch (rc)
		{
			case B_BAD_VALUE:
				strcpy(errMsg, "The folder cannot be created because an "
				"invalid folder name was given (possibly because of illegal characters)");
				break;
			case B_FILE_EXISTS:
				strcpy(errMsg, "The folder cannot be created because the name "
				"given is already in use");
				break;
				
			case B_NAME_TOO_LONG :		
				strcpy(errMsg, "The folder cannot be created because the name "
				"given is too long");
				break;
				
			case B_NOT_ALLOWED:
				strcpy(errMsg, "The folder cannot be created because the target "
				"volume is read-only");
				break;
				
			case B_PERMISSION_DENIED:
				strcpy(errMsg, "The folder cannot be created because you do not "
				"have sufficient privileges on the target folder");
				break;
				
			default	:
				sprintf(errMsg, "The folder cannot be created because an unexpected error "
				"occurred. (error code=0x%lx)", rc);
		}
		
	
		BAlert *alert=new BAlert("Error", errMsg, "OK");
		alert->Go();
		return;
		
	}
	else
		Quit();
}		
开发者ID:HaikuArchives,项目名称:Seeker,代码行数:68,代码来源:SFileWorker.cpp

示例15: entry

void
DataTranslationsApplication::RefsReceived(BMessage* message)
{
	BTranslatorRoster* roster = BTranslatorRoster::Default();

	BPath path;
	status_t status = find_directory(B_USER_ADDONS_DIRECTORY, &path, true);
	if (status != B_OK) {
		_InstallError("translator", status);
		return;
	}

	BDirectory target;
	status = target.SetTo(path.Path());
	if (status == B_OK) {
		if (!target.Contains("Translators"))
			status = target.CreateDirectory("Translators", &target);
		else
			status = target.SetTo(&target, "Translators");
	}
	if (status != B_OK) {
		_InstallError("translator", status);
		return;
	}

	int32 i = 0;
	entry_ref ref;
	while (message->FindRef("refs", i++, &ref) == B_OK) {
		if (!roster->IsTranslator(&ref)) {
			_NoTranslatorError(ref.name);
			continue;
		}

		BEntry entry(&ref, true);
		status = entry.InitCheck();
		if (status != B_OK) {
			_InstallError(ref.name, status);
			continue;
		}

		if (target.Contains(ref.name)) {
			BString string(
				B_TRANSLATE("An item named '%name' already exists in the "
				"Translators folder! Shall the existing translator be "
				"overwritten?"));
			string.ReplaceAll("%name", ref.name);

			BAlert* alert = new BAlert(B_TRANSLATE("DataTranslations - Note"),
				string.String(), B_TRANSLATE("Cancel"),
				B_TRANSLATE("Overwrite"));
			alert->SetShortcut(0, B_ESCAPE);
			if (alert->Go() != 1)
				continue;

			// the original file will be replaced
		}

		// find out whether we need to copy it or not

		status = _Install(target, entry);
		if (status == B_OK) {
			BAlert* alert = new BAlert(B_TRANSLATE("DataTranslations - Note"),
				B_TRANSLATE("The new translator has been installed "
					"successfully."), B_TRANSLATE("OK"));
			alert->Go(NULL);
		} else
			_InstallError(ref.name, status);
	}
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:69,代码来源:DataTranslations.cpp


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