Less hardcoding of paths. Adding shared private OpenWithTracker().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33207 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2009 Haiku Inc.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _OPEN_WITH_TRACKER_H
|
||||
#define _OPEN_WITH_TRACKER_H
|
||||
|
||||
|
||||
#include <Entry.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Message.h>
|
||||
#include <Messenger.h>
|
||||
#include <Path.h>
|
||||
|
||||
|
||||
status_t
|
||||
OpenWithTracker(const entry_ref* ref)
|
||||
{
|
||||
status_t status;
|
||||
BMessage message(B_REFS_RECEIVED);
|
||||
message.AddRef("refs", ref);
|
||||
|
||||
BMessenger tracker("application/x-vnd.Be-TRAK");
|
||||
status = tracker.SendMessage(&message);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
OpenWithTracker(const char* path)
|
||||
{
|
||||
status_t status;
|
||||
entry_ref ref;
|
||||
status = get_ref_for_path(path, &ref);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return OpenWithTracker(&ref);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
OpenWithTracker(directory_which which, const char* relativePath,
|
||||
bool createDirectory = false, BVolume* volume = NULL)
|
||||
{
|
||||
status_t status;
|
||||
BPath path;
|
||||
find_directory(which, &path, createDirectory, volume);
|
||||
path.Append(relativePath);
|
||||
|
||||
entry_ref ref;
|
||||
BEntry entry(path.Path());
|
||||
|
||||
if (!entry.Exists())
|
||||
return B_NAME_NOT_FOUND;
|
||||
|
||||
status = entry.GetRef(&ref);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return OpenWithTracker(&ref);
|
||||
}
|
||||
|
||||
|
||||
#endif // _OPEN_WITH_TRACKER_H
|
||||
|
||||
Reference in New Issue
Block a user