2013-02-21 01:20:53 +04:00
|
|
|
/*
|
2014-06-19 03:10:45 +04:00
|
|
|
* Copyright 2002-2014 Haiku, Inc. All rights reserved.
|
2013-02-21 01:20:53 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Tyler Dauwalder
|
|
|
|
* John Scipione, jscipione@gmail.com
|
|
|
|
* Ingo Weinhold, bonefish@users.sf.net
|
|
|
|
*
|
|
|
|
* Corresponds to:
|
2014-06-19 03:10:45 +04:00
|
|
|
* headers/os/storage/SymLink.h hrev47402
|
|
|
|
* src/kits/storage/SymLink.cpp hrev47402
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-02-22 05:14:58 +04:00
|
|
|
\file SymLink.h
|
2013-02-21 01:20:53 +04:00
|
|
|
\ingroup storage
|
|
|
|
\ingroup libbe
|
|
|
|
\brief Provides the BSymLink class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class BSymLink
|
|
|
|
\ingroup storage
|
|
|
|
\ingroup libbe
|
|
|
|
\brief Provides an interface for creating, manipulating, and accessing
|
|
|
|
the contents of symbolic links.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BSymLink::BSymLink()
|
|
|
|
\brief Creates an uninitialized BSymLink object.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BSymLink::BSymLink(const BSymLink& other)
|
2013-02-21 01:20:53 +04:00
|
|
|
\brief Creates a copy of the supplied BSymLink object.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\param other The BSymLink object to be copied.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BSymLink::BSymLink(const entry_ref* ref)
|
2013-02-21 01:20:53 +04:00
|
|
|
\brief Creates a BSymLink object and initializes it to the symbolic link
|
|
|
|
referred to by the supplied entry_ref.
|
|
|
|
|
|
|
|
\param ref the entry_ref referring to the symbolic link.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BSymLink::BSymLink(const BEntry* entry)
|
2013-02-21 01:20:53 +04:00
|
|
|
\brief Creates a BSymLink object and initializes it to the symbolic link
|
|
|
|
referred to by the supplied BEntry.
|
|
|
|
|
|
|
|
\param entry The BEntry referring to the symbolic link.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BSymLink::BSymLink(const char* path)
|
2013-02-21 01:20:53 +04:00
|
|
|
\brief Creates a BSymLink object and initializes it to the symbolic link
|
|
|
|
referred to by the supplied path name.
|
|
|
|
|
|
|
|
\param path The path of the symbolic link.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn BSymLink::BSymLink(const BDirectory* dir, const char* path)
|
2013-02-21 01:20:53 +04:00
|
|
|
\brief Creates a BSymLink object and initializes it to the symbolic link
|
|
|
|
referred to by the supplied path name relative to the specified
|
|
|
|
BDirectory.
|
|
|
|
|
|
|
|
\param dir The base BDirectory.
|
|
|
|
\param path The path of the symbolic link relative to \a dir.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BSymLink::~BSymLink()
|
|
|
|
\brief Destroys the object and frees all allocated resources.
|
|
|
|
|
|
|
|
If the BSymLink was properly initialized, the file descriptor of the
|
|
|
|
symbolic link is also closed.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn ssize_t BSymLink::ReadLink(char* buffer, size_t size)
|
2013-02-21 01:20:53 +04:00
|
|
|
\brief Reads the contents of the symbolic link into \a buffer.
|
|
|
|
|
|
|
|
The string written to the buffer is guaranteed to be \c NULL terminated.
|
|
|
|
|
|
|
|
\param buffer The buffer to read the symlink's contents into.
|
|
|
|
\param size The size of \a buffer.
|
|
|
|
|
|
|
|
\return The number of bytes written into the buffer or an error code.
|
|
|
|
\retval B_BAD_VALUE \a buf was \c NULL or the object didn't refer to a
|
|
|
|
symbolic link.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn ssize_t BSymLink::MakeLinkedPath(const char* dirPath, BPath* path)
|
2013-02-21 01:20:53 +04:00
|
|
|
\brief Combines a directory path and the contents of this symbolic link to
|
|
|
|
form an absolute path.
|
|
|
|
|
|
|
|
\param dirPath The base directory path to combine with the symbolic link.
|
|
|
|
\param path The BPath object to be set to the resulting absolute path.
|
|
|
|
|
|
|
|
\return The length of the resulting path name or an error code.
|
|
|
|
\retval B_BAD_VALUE \a dirPath or \a path was \c NULL or the object didn't
|
|
|
|
refer to a symbolic link.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized.
|
|
|
|
\retval B_NAME_TOO_LONG The resulting path name was too long to fit.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-19 03:10:45 +04:00
|
|
|
\fn ssize_t BSymLink::MakeLinkedPath(const BDirectory* dir, BPath* path)
|
2013-02-21 01:20:53 +04:00
|
|
|
\brief Combines a directory path and the contents of this symbolic link to
|
|
|
|
form an absolute path.
|
|
|
|
|
|
|
|
\param dir The base BDirectory object to combine with the symbolic link.
|
|
|
|
\param path the BPath object to be set to the resulting absolute path.
|
|
|
|
|
|
|
|
\return The length of the resulting path name or an error code.
|
|
|
|
\retval B_BAD_VALUE \a dir or \a path was \c NULL or the object didn't
|
|
|
|
refer to a symbolic link.
|
|
|
|
\retval B_FILE_ERROR The object was not initialized.
|
|
|
|
\retval B_NAME_TOO_LONG The resulting path name was too long to fit.
|
2014-06-19 03:10:45 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BSymLink::IsAbsolute()
|
|
|
|
\brief Returns whether or not the object refers to an absolute path.
|
|
|
|
|
|
|
|
/return \c true if the object is properly initialized and the symbolic
|
|
|
|
link refers to an absolute path, \c false otherwise.
|
|
|
|
|
2014-06-19 03:10:45 +04:00
|
|
|
\since BeOS R3
|
2013-02-21 01:20:53 +04:00
|
|
|
*/
|