symlink.h revision c9579522f347fc3fda6b3f4add0b355981cd7758
/** @file
* IPRT - Symbolic Link Manipulation.
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___iprt_symlink_h
#define ___iprt_symlink_h
/** @defgroup grp_rt_symlink RTSymlink - Symbolic Link Manipulation
* @ingroup grp_rt
*
* For querying and changing symlink info (mode, ownership, etc) please refer
* to the @ref grp_rt_path "RTPath" API: RTPathQueryInfoEx, RTPathSetOwnerEx,
* RTPathSetModeEx and RTPathSetTimesEx.
*
* @{
*/
/**
* Checks if the specified path exists and is a symlink.
*
* @returns true if it's a symlink, false if it isn't.
* @param pszSymlink The path to the symlink.
*
* @sa RTDirExists, RTPathExists, RTSymlinkExists.
*/
/**
* Checks if this is a dangling link or not.
*
* If the target of @a pszSymlink is a symbolic link, this may return false if
* that or any subsequent links are dangling.
*
* @returns true if it's dangling, false if it isn't.
* @param pszSymlink The path to the symlink.
*/
/**
* RTSymlinkCreate link type argument.
*/
typedef enum RTSYMLINKTYPE
{
/** Invalid value. */
/** The link targets a directory. */
/** The link targets a file (or whatever else). */
/** It is not known what is being targeted.
* @remarks The RTSymlinkCreate API may probe the target to try figure
* out what is being targeted. */
/** The end of the valid type values. */
/** Blow the type up to 32-bit. */
RTSYMLINKTYPE_32BIT_HACK = 0x7fffffff
/**
* Creates a symbolic link (@a pszSymlink) targeting @a pszTarget.
*
* @returns IPRT status code.
*
* @param pszSymlink The name of the symbolic link.
* @param pszTarget The path to the symbolic link target. This is
* relative to @a pszSymlink.
* @param enmType The symbolic link type. For Windows compatability
* it is very important to set this correctly. When
* RTSYMLINKTYPE_UNKNOWN is used, the API will try
* make a guess and may attempt query information
* about @a pszTarget in the process.
*/
/**
* Deletes the specified symbolic link.
*
* This will try to refuse deleting non-symlinks, however there are usually
* races in the implementation of this check so no guarantees can be are made.
*
* @returns IPRT status code.
* @retval VERR_NOT_SYMLINK if @a pszSymlink does not specify a symbolic link.
*
* @param pszSymlink The symbolic link that should be removed.
*/
/**
* Read the symlink target.
*
* @returns IPRT status code.
* @retval VERR_NOT_SYMLINK if @a pszSymlink does not specify a symbolic link.
* @retval VERR_BUFFER_OVERFLOW if the link is larger than @a cbTarget. The
* buffer will contain what all we managed to read, fully terminated
* if @a cbTarget > 0.
*
* @param pszSymlink The symbolic link that should be read.
* @param pszTarget The target buffer.
* @param cbTarget The size of the target buffer.
*/
/**
* Read the symlink target into an API allocated buffer.
*
* This API eliminates the race involved in determining the right buffer size.
*
* @returns IPRT status code.
* @retval VERR_NOT_SYMLINK if @a pszSymlink does not specify a symbolic link.
*
* @param pszSymlink The symbolic link that should be read.
* @param ppszTarget Where to return the target string. Free the string
* by calling RTStrFree.
*/
/** @} */
#endif