本文整理汇总了C++中BDirectory::CreateSymLink方法的典型用法代码示例。如果您正苦于以下问题:C++ BDirectory::CreateSymLink方法的具体用法?C++ BDirectory::CreateSymLink怎么用?C++ BDirectory::CreateSymLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BDirectory
的用法示例。
在下文中一共展示了BDirectory::CreateSymLink方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//------------------------------------------------------------------------------
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;
}
示例2:
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;
}
示例3: entry
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);
}
}
}
}
示例4: str
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(),
//.........这里部分代码省略.........
示例5: linkName
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));
}
//.........这里部分代码省略.........
示例6: CopyLink
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;
}