Ejemplo n.º 1
0
//------------------------------------------------------------------------------
status_t	install_asst()
{
	string		aAsstRealPath;	// 実体のパス
	BDirectory	aDir;
	BEntry		aEntry;

	uninstall_asst(true);
	aAsstRealPath = gAppPrivacy.ExePath()+FILE_NAME_ASST;
	// Hot Key Spy
	aDir.CreateSymLink(asst_install_path(FOLDER_NAME_ASST_SPY).c_str(), aAsstRealPath.c_str(), NULL);
	// Paste Sender
	aDir.CreateSymLink(asst_install_path(FOLDER_NAME_ASST_PASTE_SENDER).c_str(), aAsstRealPath.c_str(), NULL);
	if ( !is_asst_installed() )
		return B_ERROR;
	return B_OK;
}
Ejemplo n.º 2
0
int32_t
PDirectoryCreateSymLink(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;
	
	BString target;
	if (args->FindString("target", &target) != B_OK)
		return B_ERROR;
	
	BSymLink link;
	status_t status = backend->CreateSymLink(path.String(),
											target.String(), &link);
	
	outArgs->MakeEmpty();
	outArgs->AddInt32("status", status);
	
	return B_OK;
}
Ejemplo n.º 3
0
bool
DeskbarView::_CreateMenuLinks(BDirectory& directory, BPath& path)
{
	status_t status = directory.SetTo(path.Path());
	if (status == B_OK)
		return true;

	// Check if the directory has to be created (and do it in this case,
	// filling it with some standard links).  Normally the installer will
	// create the directory and fill it with links, so normally this doesn't
	// get used.

	BEntry entry(path.Path());
	if (status != B_ENTRY_NOT_FOUND
		|| entry.GetParent(&directory) < B_OK
		|| directory.CreateDirectory(path.Leaf(), NULL) < B_OK
		|| directory.SetTo(path.Path()) < B_OK)
		return false;

	BPath targetPath;
	find_directory(B_USER_DIRECTORY, &targetPath);
	targetPath.Append("mail/in");

	directory.CreateSymLink("Open Inbox Folder", targetPath.Path(), NULL);
	targetPath.GetParent(&targetPath);
	directory.CreateSymLink("Open Mail Folder", targetPath.Path(), NULL);

	// create the draft query

	BFile file;
	if (directory.CreateFile("Open Draft", &file) < B_OK)
		return true;

	BString string("MAIL:draft==1");
	file.WriteAttrString("_trk/qrystr", &string);
	string = "E-mail";
	file.WriteAttrString("_trk/qryinitmime", &string);
	BNodeInfo(&file).SetType("application/x-vnd.Be-query");

	return true;
}
Ejemplo n.º 4
0
void
AddRefsToDeskbarMenu(const BMessage* m, entry_ref* subdirectory)
{
	if (m) {
		int32 count = 0;
		uint32 type = 0;
		entry_ref ref;

		m->GetInfo("refs", &type, &count);
		if (count <= 0)
			return;

		BPath path;
		BSymLink link;
		BDirectory dir;
		if (subdirectory) {
			ref = *subdirectory;
			BEntry entry(&ref);
			if (entry.Exists()) {
				// if the ref is a file get the parent and convert it to a ref
				if (entry.IsFile()) {
					BEntry parent;
					entry.GetParent(&parent);
					parent.GetRef(&ref);
				}
			} else
				return;

			dir.SetTo(&ref);
		} else {
			if (find_directory(B_USER_DESKBAR_DIRECTORY, &path) == B_OK)
				dir.SetTo(path.Path());
			else
				return;
		}

		for (long i = 0; i < count; i++) {
			if (m->FindRef("refs", i, &ref) == B_NO_ERROR) {
				BEntry entry(&ref);
				entry.GetPath(&path);

				dir.CreateSymLink(ref.name, path.Path(), &link);
			}
		}
	}
}
Ejemplo n.º 5
0
void
JoyWin::MessageReceived(BMessage *message)
{
//	message->PrintToStream();
	switch(message->what)
	{
		case DISABLEPORT:
		break;
		{
			PortItem *item = _GetSelectedItem(fGamePortL);
			if (item != NULL) {
				//ToDo: item->SetEnabled(true);
				//don't work as you can't select a item that are disabled
				if(fCheckbox->Value()) {
					item->SetEnabled(false);
					_SelectDeselectJoystick(fConControllerL, false);
				} else {
					item->SetEnabled(true);
					_SelectDeselectJoystick(fConControllerL, true);
					_PerformProbe(item->Text());
				}
			} //else
				//printf("We have a null value\n");
		break;
		}

		case PORT_SELECTED:
		{
			PortItem *item = _GetSelectedItem(fGamePortL);
			if (item != NULL) {
				fSystemUsedSelect = true;
				if (item->IsEnabled()) {
					//printf("SetEnabled = false\n");
					fCheckbox->SetValue(false);
					_SelectDeselectJoystick(fConControllerL, true);
				} else {
					//printf("SetEnabled = true\n");
					fCheckbox->SetValue(true);
					_SelectDeselectJoystick(fConControllerL, false);
				}

				if (_CheckJoystickExist(item->Text()) == B_ERROR) {
					if (_ShowCantFindFileMessage(item->Text()) == B_OK) {
						_PerformProbe(item->Text());
					}
				} else {
					BString str(_FindFilePathForSymLink(JOYSTICKFILESETTINGS,
						item));
					if (str != NULL) {
						BString str(_FixPathToName(str.String()));
						int32 id = _FindStringItemInList(fConControllerL,
									new PortItem(str.String()));
						if (id > -1) {
							fConControllerL->Select(id);
							item->SetJoystickName(BString(str.String()));
						}
					}
				}
			} else {
				fConControllerL->DeselectAll();
				ShowMessage((char*)SELECTGAMEPORTFIRST);
			}
		break;
		}

		case PROBE:
		case PORT_INVOKE:
		{
			PortItem *item = _GetSelectedItem(fGamePortL);
			if (item != NULL) {
				//printf("invoke.. inte null\n");
				_PerformProbe(item->Text());
			} else
				ShowMessage((char*)SELECTGAMEPORTFIRST);
		break;
		}

		case JOY_SELECTED:
		{
			if (!fSystemUsedSelect) {
				PortItem *controllerName = _GetSelectedItem(fConControllerL);
				PortItem *portname = _GetSelectedItem(fGamePortL);
				if (portname != NULL && controllerName != NULL) {
					portname->SetJoystickName(BString(controllerName->Text()));

					BString str = portname->GetOldJoystickName();
					if (str != NULL) {
						BString strOldFile(JOYSTICKFILESETTINGS);
						strOldFile.Append(portname->Text());
						BEntry entry(strOldFile.String());
						entry.Remove();
					}
					BString strLinkPlace(JOYSTICKFILESETTINGS);
					strLinkPlace.Append(portname->Text());

					BString strLinkTo(JOYSTICKFILEPATH);
					strLinkTo.Append(controllerName->Text());

					BDirectory *dir = new BDirectory();
					dir->CreateSymLink(strLinkPlace.String(),
						strLinkTo.String(), NULL);
				} else
					ShowMessage((char*)SELECTGAMEPORTFIRST);
			}

			fSystemUsedSelect = false;
		break;
		}

		case CALIBRATE:
		case JOY_INVOKE:
		{
			PortItem *controllerName = _GetSelectedItem(fConControllerL);
			PortItem *portname = _GetSelectedItem(fGamePortL);
			if (portname != NULL) {
				if (controllerName == NULL)
					_ShowNoDeviceConnectedMessage("known", portname->Text());
				else {
					_ShowNoDeviceConnectedMessage(controllerName->Text(), portname->Text());
					/*
					ToDo:
					Check for a device, and show calibrate window if so
					*/
				}
			} else
				ShowMessage((char*)SELECTGAMEPORTFIRST);
		break;
		}
		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Ejemplo n.º 6
0
status_t
PackageLink::WriteToPath(const char *path, ItemState *state)
{
	if (state == NULL)
		return B_ERROR;

	status_t ret = B_OK;
	BSymLink symlink;
	parser_debug("Symlink: %s WriteToPath() called!\n", fPath.String());

	BPath &destination = state->destination;
	BDirectory *dir = &state->parent;

	if (state->status == B_NO_INIT || destination.InitCheck() != B_OK
		|| dir->InitCheck() != B_OK) {
		// Not yet initialized
		ret = InitPath(path, &destination);
		if (ret != B_OK)
			return ret;

		BString linkName(destination.Leaf());
		parser_debug("%s:%s:%s\n", fPath.String(), destination.Path(),
			linkName.String());

		BPath dirPath;
		ret = destination.GetParent(&dirPath);
		ret = dir->SetTo(dirPath.Path());

		if (ret == B_ENTRY_NOT_FOUND) {
			ret = create_directory(dirPath.Path(), kDefaultMode);
			if (ret != B_OK) {
				parser_debug("create_directory()) failed\n");
				return B_ERROR;
			}
		}
		if (ret != B_OK) {
			parser_debug("destination InitCheck failed %s for %s\n",
				strerror(ret), dirPath.Path());
			return ret;
		}

		ret = dir->CreateSymLink(destination.Path(), fLink.String(), &symlink);
		if (ret == B_FILE_EXISTS) {
			// We need to check if the existing symlink is pointing at the same path
			// as our new one - if not, let's prompt the user
			symlink.SetTo(destination.Path());
			BPath oldLink;

			ret = symlink.MakeLinkedPath(dir, &oldLink);
			chdir(dirPath.Path());

			if (ret == B_BAD_VALUE || oldLink != fLink.String())
				state->status = ret = B_FILE_EXISTS;
			else
				ret = B_OK;
		}
	}

	if (state->status == B_FILE_EXISTS) {
		switch (state->policy) {
			case P_EXISTS_OVERWRITE:
			{
				BEntry entry;
				ret = entry.SetTo(destination.Path());
				if (ret != B_OK)
					return ret;

				entry.Remove();
				ret = dir->CreateSymLink(destination.Path(), fLink.String(),
					&symlink);
				break;
			}

			case P_EXISTS_NONE:
			case P_EXISTS_ASK:
				ret = B_FILE_EXISTS;
				break;

			case P_EXISTS_SKIP:
				return B_OK;
		}
	}

	if (ret != B_OK) {
		parser_debug("CreateSymLink failed\n");
		return ret;
	}

	parser_debug(" Symlink created!\n");

	ret = symlink.SetPermissions(static_cast<mode_t>(fMode));

	if (fCreationTime && ret == B_OK)
		ret = symlink.SetCreationTime(static_cast<time_t>(fCreationTime));

	if (fModificationTime && ret == B_OK) {
		ret = symlink.SetModificationTime(static_cast<time_t>(
			fModificationTime));
	}

	if (ret != B_OK) {
		parser_debug("Failed to set symlink attributes\n");
		return ret;
	}

	if (fOffset) {
		// Symlinks also seem to have attributes - so parse them
		ret = HandleAttributes(&destination, &symlink, "LnDa");
	}

	return ret;
}
bool GenesisCopyWindow::CopyLink(const char *linkname, const char *destination, const char *destfilename)
////////////////////////////////////////////////////////////////////////
{
	BSymLink srclink;
	BSymLink dstlink;
	BDirectory dstdir;
	BEntry srcentry;
	BEntry symlinkentry;
	BPath LinkPath;
	char name[B_FILE_NAME_LENGTH];
	struct stat statbuf;
	entry_ref ref;
		
	srcentry.SetTo(linkname);
	srcentry.GetName(name);
	srcentry.GetRef(&ref);
	symlinkentry.SetTo(&ref, true);
	symlinkentry.GetPath(&LinkPath);

	if (destfilename)
		sprintf(name,"%s",destfilename);
	
	if (srcentry.GetStat(&statbuf)!=B_OK)
		return false;

	dstdir.SetTo(destination);
	
	if (dstdir.InitCheck()!=B_OK)
		return false;

	Lock();
	m_FileBar->Update(-m_FileBar->CurrentValue());	// Reset to 0.0
	m_FileBar->SetMaxValue(1);
	m_FileBar->SetTrailingText(name);
	Unlock();

	if (dstdir.CreateSymLink(name, LinkPath.Path(), &dstlink)!=B_OK && !m_SkipSymLinkCreationError)
	{
		BString text;
		
		text << "Cannot create '" << name << "' symbolic link in '" << LinkPath.Path() << "'";
		
		BAlert *myAlert = new BAlert("Copy",text.String(),"Abort","Skip all","Skip",B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT);
		myAlert->SetShortcut(0, B_ESCAPE);
		switch (myAlert->Go())
		{
			case 0:
				Close();
				kill_thread(m_CopyThread);
				break;
			case 1:
				m_SkipSymLinkCreationError = true;
				break;
		}	

		return false;
	}

	Lock();
	m_FileBar->Update(1);
	Unlock();
		
	dstlink.SetPermissions(statbuf.st_mode);
	dstlink.SetOwner(statbuf.st_uid);
	dstlink.SetGroup(statbuf.st_gid);
	dstlink.SetModificationTime(statbuf.st_mtime);
	dstlink.SetCreationTime(statbuf.st_crtime);

	// Copy attributes...
	BString destlinkname;
	destlinkname.SetTo("");
	destlinkname << destination << "/" << name;
	CopyAttr(linkname, destlinkname.String());

	return true;
}