vfs: check userland buffers before reading them.
[haiku.git] / headers / private / shared / OpenWithTracker.h
blob26eceeb1a80a83be89e28590c11af859a08f8172
1 /*
2 * Copyright 2009 Haiku Inc.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5 #ifndef _OPEN_WITH_TRACKER_H
6 #define _OPEN_WITH_TRACKER_H
9 #include <Entry.h>
10 #include <FindDirectory.h>
11 #include <Message.h>
12 #include <Messenger.h>
13 #include <Path.h>
16 status_t
17 OpenWithTracker(const entry_ref* ref)
19 status_t status;
20 BMessage message(B_REFS_RECEIVED);
21 message.AddRef("refs", ref);
23 BMessenger tracker("application/x-vnd.Be-TRAK");
24 status = tracker.SendMessage(&message);
25 return status;
29 status_t
30 OpenWithTracker(const char* path)
32 status_t status;
33 entry_ref ref;
34 status = get_ref_for_path(path, &ref);
35 if (status != B_OK)
36 return status;
38 return OpenWithTracker(&ref);
42 status_t
43 OpenWithTracker(directory_which which, const char* relativePath = NULL,
44 bool createDirectory = false, BVolume* volume = NULL)
46 status_t status;
47 BPath path;
48 find_directory(which, &path, createDirectory, volume);
50 if (relativePath)
51 path.Append(relativePath);
53 entry_ref ref;
54 BEntry entry(path.Path());
56 if (!entry.Exists())
57 return B_NAME_NOT_FOUND;
59 status = entry.GetRef(&ref);
60 if (status != B_OK)
61 return status;
63 return OpenWithTracker(&ref);
67 #endif // _OPEN_WITH_TRACKER_H