xref: /haiku/docs/user/storage/SymLink.dox (revision b885e90eb96c5c2b629c81d35b7f9970db239995)
1434716ceSJohn Scipione/*
2*b885e90eSJohn Scipione * Copyright 2002-2014 Haiku, Inc. All rights reserved.
3434716ceSJohn Scipione * Distributed under the terms of the MIT License.
4434716ceSJohn Scipione *
5434716ceSJohn Scipione * Authors:
6434716ceSJohn Scipione *		Tyler Dauwalder
7434716ceSJohn Scipione *		John Scipione, jscipione@gmail.com
8434716ceSJohn Scipione *		Ingo Weinhold, bonefish@users.sf.net
9434716ceSJohn Scipione *
10434716ceSJohn Scipione * Corresponds to:
11*b885e90eSJohn Scipione *		headers/os/storage/SymLink.h	hrev47402
12*b885e90eSJohn Scipione *		src/kits/storage/SymLink.cpp	hrev47402
13434716ceSJohn Scipione */
14434716ceSJohn Scipione
15434716ceSJohn Scipione
16434716ceSJohn Scipione/*!
177635a303SJohn Scipione	\file SymLink.h
18434716ceSJohn Scipione	\ingroup storage
19434716ceSJohn Scipione	\ingroup libbe
20434716ceSJohn Scipione	\brief Provides the BSymLink class.
21434716ceSJohn Scipione*/
22434716ceSJohn Scipione
23434716ceSJohn Scipione
24434716ceSJohn Scipione/*!
25434716ceSJohn Scipione	\class BSymLink
26434716ceSJohn Scipione	\ingroup storage
27434716ceSJohn Scipione	\ingroup libbe
28434716ceSJohn Scipione	\brief Provides an interface for creating, manipulating, and accessing
29434716ceSJohn Scipione	       the contents of symbolic links.
30*b885e90eSJohn Scipione
31*b885e90eSJohn Scipione	\since BeOS R3
32434716ceSJohn Scipione*/
33434716ceSJohn Scipione
34434716ceSJohn Scipione
35434716ceSJohn Scipione/*!
36434716ceSJohn Scipione	\fn BSymLink::BSymLink()
37434716ceSJohn Scipione	\brief Creates an uninitialized BSymLink object.
38*b885e90eSJohn Scipione
39*b885e90eSJohn Scipione	\since BeOS R3
40434716ceSJohn Scipione*/
41434716ceSJohn Scipione
42434716ceSJohn Scipione
43434716ceSJohn Scipione/*!
44*b885e90eSJohn Scipione	\fn BSymLink::BSymLink(const BSymLink& other)
45434716ceSJohn Scipione	\brief Creates a copy of the supplied BSymLink object.
46434716ceSJohn Scipione
47*b885e90eSJohn Scipione	\param other The BSymLink object to be copied.
48*b885e90eSJohn Scipione
49*b885e90eSJohn Scipione	\since BeOS R3
50434716ceSJohn Scipione*/
51434716ceSJohn Scipione
52434716ceSJohn Scipione
53434716ceSJohn Scipione/*!
54434716ceSJohn Scipione	\fn BSymLink::BSymLink(const entry_ref* ref)
55434716ceSJohn Scipione	\brief Creates a BSymLink object and initializes it to the symbolic link
56434716ceSJohn Scipione	       referred to by the supplied entry_ref.
57434716ceSJohn Scipione
58434716ceSJohn Scipione	\param ref the entry_ref referring to the symbolic link.
59*b885e90eSJohn Scipione
60*b885e90eSJohn Scipione	\since BeOS R3
61434716ceSJohn Scipione*/
62434716ceSJohn Scipione
63434716ceSJohn Scipione
64434716ceSJohn Scipione/*!
65434716ceSJohn Scipione	\fn BSymLink::BSymLink(const BEntry* entry)
66434716ceSJohn Scipione	\brief Creates a BSymLink object and initializes it to the symbolic link
67434716ceSJohn Scipione	       referred to by the supplied BEntry.
68434716ceSJohn Scipione
69434716ceSJohn Scipione	\param entry The BEntry referring to the symbolic link.
70*b885e90eSJohn Scipione
71*b885e90eSJohn Scipione	\since BeOS R3
72434716ceSJohn Scipione*/
73434716ceSJohn Scipione
74434716ceSJohn Scipione
75434716ceSJohn Scipione/*!
76434716ceSJohn Scipione	\fn BSymLink::BSymLink(const char* path)
77434716ceSJohn Scipione	\brief Creates a BSymLink object and initializes it to the symbolic link
78434716ceSJohn Scipione	       referred to by the supplied path name.
79434716ceSJohn Scipione
80434716ceSJohn Scipione	\param path The path of the symbolic link.
81*b885e90eSJohn Scipione
82*b885e90eSJohn Scipione	\since BeOS R3
83434716ceSJohn Scipione*/
84434716ceSJohn Scipione
85434716ceSJohn Scipione
86434716ceSJohn Scipione/*!
87434716ceSJohn Scipione	\fn BSymLink::BSymLink(const BDirectory* dir, const char* path)
88434716ceSJohn Scipione	\brief Creates a BSymLink object and initializes it to the symbolic link
89434716ceSJohn Scipione	       referred to by the supplied path name relative to the specified
90434716ceSJohn Scipione	       BDirectory.
91434716ceSJohn Scipione
92434716ceSJohn Scipione	\param dir The base BDirectory.
93434716ceSJohn Scipione	\param path The path of the symbolic link relative to \a dir.
94*b885e90eSJohn Scipione
95*b885e90eSJohn Scipione	\since BeOS R3
96434716ceSJohn Scipione*/
97434716ceSJohn Scipione
98434716ceSJohn Scipione
99434716ceSJohn Scipione/*!
100434716ceSJohn Scipione	\fn BSymLink::~BSymLink()
101434716ceSJohn Scipione	\brief Destroys the object and frees all allocated resources.
102434716ceSJohn Scipione
103434716ceSJohn Scipione	If the BSymLink was properly initialized, the file descriptor of the
104434716ceSJohn Scipione	symbolic link is also closed.
105*b885e90eSJohn Scipione
106*b885e90eSJohn Scipione	\since BeOS R3
107434716ceSJohn Scipione*/
108434716ceSJohn Scipione
109434716ceSJohn Scipione
110434716ceSJohn Scipione/*!
111434716ceSJohn Scipione	\fn ssize_t BSymLink::ReadLink(char* buffer, size_t size)
112434716ceSJohn Scipione	\brief Reads the contents of the symbolic link into \a buffer.
113434716ceSJohn Scipione
114434716ceSJohn Scipione	The string written to the buffer is guaranteed to be \c NULL terminated.
115434716ceSJohn Scipione
116434716ceSJohn Scipione	\param buffer The buffer to read the symlink's contents into.
117434716ceSJohn Scipione	\param size The size of \a buffer.
118434716ceSJohn Scipione
119434716ceSJohn Scipione	\return The number of bytes written into the buffer or an error code.
120434716ceSJohn Scipione	\retval B_BAD_VALUE \a buf was \c NULL or the object didn't refer to a
121434716ceSJohn Scipione	        symbolic link.
122434716ceSJohn Scipione	\retval B_FILE_ERROR The object was not initialized.
123*b885e90eSJohn Scipione
124*b885e90eSJohn Scipione	\since BeOS R3
125434716ceSJohn Scipione*/
126434716ceSJohn Scipione
127434716ceSJohn Scipione
128434716ceSJohn Scipione/*!
129434716ceSJohn Scipione	\fn ssize_t BSymLink::MakeLinkedPath(const char* dirPath, BPath* path)
130434716ceSJohn Scipione	\brief Combines a directory path and the contents of this symbolic link to
131434716ceSJohn Scipione	       form an absolute path.
132434716ceSJohn Scipione
133434716ceSJohn Scipione	\param dirPath The base directory path to combine with the symbolic link.
134434716ceSJohn Scipione	\param path The BPath object to be set to the resulting absolute path.
135434716ceSJohn Scipione
136434716ceSJohn Scipione	\return The length of the resulting path name or an error code.
137434716ceSJohn Scipione	\retval B_BAD_VALUE \a dirPath or \a path was \c NULL or the object didn't
138434716ceSJohn Scipione	        refer to a symbolic link.
139434716ceSJohn Scipione	\retval B_FILE_ERROR The object was not initialized.
140434716ceSJohn Scipione	\retval B_NAME_TOO_LONG The resulting path name was too long to fit.
141*b885e90eSJohn Scipione
142*b885e90eSJohn Scipione	\since BeOS R3
143434716ceSJohn Scipione*/
144434716ceSJohn Scipione
145434716ceSJohn Scipione
146434716ceSJohn Scipione/*!
147434716ceSJohn Scipione	\fn ssize_t BSymLink::MakeLinkedPath(const BDirectory* dir, BPath* path)
148434716ceSJohn Scipione	\brief Combines a directory path and the contents of this symbolic link to
149434716ceSJohn Scipione	       form an absolute path.
150434716ceSJohn Scipione
151434716ceSJohn Scipione	\param dir The base BDirectory object to combine with the symbolic link.
152434716ceSJohn Scipione	\param path the BPath object to be set to the resulting absolute path.
153434716ceSJohn Scipione
154434716ceSJohn Scipione	\return The length of the resulting path name or an error code.
155434716ceSJohn Scipione	\retval B_BAD_VALUE \a dir or \a path was \c NULL or the object didn't
156434716ceSJohn Scipione	        refer to a symbolic link.
157434716ceSJohn Scipione	\retval B_FILE_ERROR The object was not initialized.
158434716ceSJohn Scipione	\retval B_NAME_TOO_LONG The resulting path name was too long to fit.
159*b885e90eSJohn Scipione
160*b885e90eSJohn Scipione	\since BeOS R3
161434716ceSJohn Scipione*/
162434716ceSJohn Scipione
163434716ceSJohn Scipione
164434716ceSJohn Scipione/*!
165434716ceSJohn Scipione	\fn bool BSymLink::IsAbsolute()
166434716ceSJohn Scipione	\brief Returns whether or not the object refers to an absolute path.
167434716ceSJohn Scipione
168434716ceSJohn Scipione	/return \c true if the object is properly initialized and the symbolic
169434716ceSJohn Scipione	        link refers to an absolute path, \c false otherwise.
170434716ceSJohn Scipione
171*b885e90eSJohn Scipione	\since BeOS R3
172434716ceSJohn Scipione*/
173