xref: /haiku/headers/os/storage/SymLink.h (revision 7c44680a3623191910d7fb6617ff897583f2ef60)
1 //----------------------------------------------------------------------
2 //  This software is part of the OpenBeOS distribution and is covered
3 //  by the OpenBeOS license.
4 //
5 //  File Name: SymLink.h
6 //---------------------------------------------------------------------
7 /*!
8 	\file SymLink.h
9 	BSymLink interface declaration.
10 */
11 
12 #ifndef _SYM_LINK_H
13 #define _SYM_LINK_H
14 
15 #include <Node.h>
16 #include <StorageDefs.h>
17 
18 #ifdef USE_OPENBEOS_NAMESPACE
19 namespace OpenBeOS {
20 #endif
21 
22 /*!
23 	\class BSymLink
24 	\brief A symbolic link in the filesystem
25 
26 	Provides an interface for manipulating symbolic links.
27 
28 	\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
29 
30 	\version 0.0.0
31 */
32 class BSymLink : public BNode {
33 public:
34 	BSymLink();
35 	BSymLink(const BSymLink &link);
36 	BSymLink(const entry_ref *ref);
37 	BSymLink(const BEntry *entry);
38 	BSymLink(const char *path);
39 	BSymLink(const BDirectory *dir, const char *path);
40 	virtual ~BSymLink();
41 
42 	// WORKAROUND
43 	// SetTo() methods: Part of a work around until someone has an idea how to
44 	// get BPrivate::Storage::read_link(FileDescriptor,...) to work.
45 	status_t SetTo(const entry_ref *ref);
46 	status_t SetTo(const BEntry *entry);
47 	status_t SetTo(const char *path);
48 	status_t SetTo(const BDirectory *dir, const char *path);
49 	void Unset();
50 
51 	ssize_t ReadLink(char *buf, size_t size);
52 
53 	ssize_t MakeLinkedPath(const char *dirPath, BPath *path);
54 	ssize_t MakeLinkedPath(const BDirectory *dir, BPath *path);
55 
56 	bool IsAbsolute();
57 
58 	// WORKAROUND
59 	// operator=(): Part of a work around until someone has an idea how to
60 	// get BPrivate::Storage::read_link(FileDescriptor,...) to work.
61 	BSymLink &operator=(const BSymLink &link);
62 
63 private:
64 	virtual void _MissingSymLink1();
65 	virtual void _MissingSymLink2();
66 	virtual void _MissingSymLink3();
67 	virtual void _MissingSymLink4();
68 	virtual void _MissingSymLink5();
69 	virtual void _MissingSymLink6();
70 
71 	// WORKAROUND
72 	// fSecretEntry: Part of a work around until someone has an idea how to
73 	// get BPrivate::Storage::read_link(FileDescriptor,...) to work.
74 //	uint32 _reservedData[4];
75 	uint32 _reservedData[3];
76 	BEntry *fSecretEntry;
77 
78 private:
79 	BPrivate::Storage::FileDescriptor get_fd() const;
80 };
81 
82 #ifdef USE_OPENBEOS_NAMESPACE
83 };		// namespace OpenBeOS
84 #endif
85 
86 #endif	// _SYM_LINK_H
87 
88 
89