file.h revision 469fa3ce0437a29dc6c7484a622c4a5be0d8bf3a
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @file
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * IPRT - File I/O.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/*
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * This file is part of VirtualBox Open Source Edition (OSE), as
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * available from http://www.virtualbox.org. This file is free software;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * you can redistribute it and/or modify it under the terms of the GNU
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * General Public License (GPL) as published by the Free Software
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Foundation, in version 2 as it comes in the "COPYING" file of the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * The contents of this file may alternatively be used under the terms
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * of the Common Development and Distribution License Version 1.0
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * VirtualBox OSE distribution, in which case the provisions of the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * CDDL are applicable instead of those of the GPL.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
f4e76ddf09a338dc23da0904866290ac36274a5bNattuvetty Bhavyan * You may elect to license modified versions of this file under the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * terms and conditions of either the GPL or the CDDL or both.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Clara, CA 95054 USA or visit http://www.sun.com if you need
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * additional information or have any questions.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#ifndef ___iprt_file_h
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan#define ___iprt_file_h
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan#include <iprt/cdefs.h>
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan#include <iprt/types.h>
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan#ifdef IN_RING3
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan# include <iprt/fs.h>
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan#endif
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @todo rename this file to iprt/file.h */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto__BEGIN_DECLS
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte/** @defgroup grp_rt_fileio RTFile - File I/O
f4e76ddf09a338dc23da0904866290ac36274a5bNattuvetty Bhavyan * @ingroup grp_rt
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Platform specific text line break.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @deprecated Use text I/O streams and '\\n'. See iprt/stream.h. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan# define RTFILE_LINEFEED "\r\n"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#else
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto# define RTFILE_LINEFEED "\n"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#endif
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#ifdef IN_RING3
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @name Open flags
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @{ */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** Open the file with read access. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_READ 0x00000001
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** Open the file with write access. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_WRITE 0x00000002
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Open the file with read & write access. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_READWRITE 0x00000003
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** The file access mask.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark The value 0 is invalid. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_ACCESS_MASK 0x00000003
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Sharing mode: deny none (the default mode). */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_DENY_NONE 0x00000000
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Sharing mode: deny read. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_DENY_READ 0x00000010
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Sharing mode: deny write. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_DENY_WRITE 0x00000020
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Sharing mode: deny read and write. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_DENY_READWRITE 0x00000030
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** Sharing mode: deny all. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_DENY_ALL RTFILE_O_DENY_READWRITE
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Sharing mode: do NOT deny delete (NT).
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark This might not be implemented on all platforms,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * and will be defaulted & ignored on those.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_DENY_NOT_DELETE 0x00000040
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Sharing mode mask. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_DENY_MASK 0x00000070
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Action: Open an existing file (the default action). */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_OPEN 0x00000000
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Action: Create a new file or open an existing one. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_OPEN_CREATE 0x00000100
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Action: Create a new a file. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_CREATE 0x00000200
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Action: Create a new file or replace an existing one. */
70c284ca5360ed73476d9e94223d4905dd80b1adPeter Cudhea - Sun Microsystems - Burlington, MA United States#define RTFILE_O_CREATE_REPLACE 0x00000300
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Action mask. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_ACTION_MASK 0x00000300
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Turns off indexing of files on Windows hosts, *CREATE* only.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark This might not be implemented on all platforms,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * and will be ignored on those.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_NOT_CONTENT_INDEXED 0x00000800
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Truncate the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark This will not truncate files opened for read-only.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark The trunction doesn't have to be atomically, so anyone
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * else opening the file may be racing us. The caller is
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * responsible for not causing this race. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_TRUNCATE 0x00001000
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Make the handle inheritable on RTProcessCreate(/exec). */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_INHERIT 0x00002000
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Open file in non-blocking mode - non-portable.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark This flag may not be supported on all platforms, in which
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * case it's considered an invalid parameter.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_NON_BLOCK 0x00004000
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Write through directly to disk. Workaround to avoid iSCSI
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * initiator deadlocks on Windows hosts.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark This might not be implemented on all platforms,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * and will be ignored on those.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_WRITE_THROUGH 0x00008000
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Mask of all valid flags.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark This doesn't validate the access mode properly.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_O_VALID_MASK 0x0000FB73
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @} */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Force the use of open flags for all files opened after the setting is
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * changed. The caller is responsible for not causing races with RTFileOpen().
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param fOpenForAccess Access mode to which the set/mask settings apply.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param fSet Open flags to be forced set.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param fMask Open flags to be masked out.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileSetForceFlags(unsigned fOpenForAccess, unsigned fSet, unsigned fMask);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open a file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pFile Where to store the handle to the opened file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pszFilename Path to the file which is to be opened. (UTF-8)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param fOpen Open flags, i.e a combination of the RTFILE_O_* defines.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, unsigned fOpen);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Close a file opened by RTFileOpen().
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File The file handle to close.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileClose(RTFILE File);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Creates an IPRT file handle from a native one.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns IPRT status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pFile Where to store the IPRT file handle.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param uNative The native handle.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileFromNative(PRTFILE pFile, RTHCINTPTR uNative);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Gets the native handle for an IPRT file handle.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @return The native handle.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @params File The IPRT file handle.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE File);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Delete a file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pszFilename Path to the file which is to be deleted. (UTF-8)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @todo This is a RTPath api!
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileDelete(const char *pszFilename);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @name Seek flags.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @{ */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Seek from the start of the file. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_SEEK_BEGIN 0x00
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Seek from the current file position. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_SEEK_CURRENT 0x01
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Seek from the end of the file. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_SEEK_END 0x02
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @internal */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_SEEK_FIRST RTFILE_SEEK_BEGIN
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @internal */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_SEEK_LAST RTFILE_SEEK_END
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @} */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Changes the read & write position in a file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param offSeek Offset to seek.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param uMethod Seek method, i.e. one of the RTFILE_SEEK_* defines.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param poffActual Where to store the new file position.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * NULL is allowed.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileSeek(RTFILE File, int64_t offSeek, unsigned uMethod, uint64_t *poffActual);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Read bytes from a file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pvBuf Where to put the bytes we read.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param cbToRead How much to read.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param *pcbRead How much we actually read .
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If NULL an error will be returned for a partial read.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Read bytes from a file at a given offset.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * This function may modify the file position.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param off Where to read.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pvBuf Where to put the bytes we read.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param cbToRead How much to read.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param *pcbRead How much we actually read .
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If NULL an error will be returned for a partial read.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Write bytes to a file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pvBuf What to write.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param cbToWrite How much to write.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param *pcbWritten How much we actually wrote.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If NULL an error will be returned for a partial write.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Write bytes to a file at a given offset.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * This function may modify the file position.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param off Where to write.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pvBuf What to write.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param cbToWrite How much to write.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param *pcbWritten How much we actually wrote.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If NULL an error will be returned for a partial write.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Flushes the buffers for the specified file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileFlush(RTFILE File);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Set the size of the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * @param cbSize The new file size.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan */
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty BhavyanRTR3DECL(int) RTFileSetSize(RTFILE File, uint64_t cbSize);
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan/**
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * Query the size of the file.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan *
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * @returns iprt status code.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * @param File Handle to the file.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * @param pcbSize Where to store the filesize.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan */
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty BhavyanRTR3DECL(int) RTFileGetSize(RTFILE File, uint64_t *pcbSize);
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan/**
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * Determine the maximum file size.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan *
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * @returns The max size of the file.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * -1 on failure, the file position is undefined.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @see RTFileGetMaxSizeEx.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(RTFOFF) RTFileGetMaxSize(RTFILE File);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Determine the maximum file size.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns IPRT status code.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pcbMax Where to store the max file size.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @see RTFileGetMaxSize.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Determine the maximum file size depending on the file system the file is stored on.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns The max size of the file.
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan * -1 on failure.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(RTFOFF) RTFileGetMaxSize(RTFILE File);
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Gets the current file position.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns File offset.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns ~0UUL on failure.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTDECL(uint64_t) RTFileTell(RTFILE File);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Checks if the supplied handle is valid.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns true if valid.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns false if invalid.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File The file handle
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(bool) RTFileIsValid(RTFILE File);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Copies a file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_ALREADY_EXISTS if the destination file exists.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VBox Status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pszSrc The path to the source file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param pszDst The path to the destination file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * This file will be created.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTDECL(int) RTFileCopy(const char *pszSrc, const char *pszDst);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Copies a file given the handles to both files.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @returns VBox Status code.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param FileSrc The source file. The file position is unaltered.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param FileDst The destination file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * On successful returns the file position is at the end of the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * On failures the file position and size is undefined.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan */
716c180559045549271833327182dc6a266134f1Nattuvetty BhavyanRTDECL(int) RTFileCopyByHandles(RTFILE FileSrc, RTFILE FileDst);
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** Flags for RTFileCopyEx().
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @{ */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** Do not use RTFILE_O_DENY_WRITE on the source file to allow for copying files opened for writing. */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan#define RTFILECOPY_FLAGS_NO_SRC_DENY_WRITE RT_BIT(0)
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** Do not use RTFILE_O_DENY_WRITE on the target file. */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan#define RTFILECOPY_FLAGS_NO_DST_DENY_WRITE RT_BIT(1)
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** Do not use RTFILE_O_DENY_WRITE on either of the two files. */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan#define RTFILECOPY_FLAGS_NO_DENY_WRITE ( RTFILECOPY_FLAGS_NO_SRC_DENY_WRITE | RTFILECOPY_FLAGS_NO_DST_DENY_WRITE )
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan#define RTFILECOPY_FLAGS_MASK UINT32_C(0x00000003)
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** @} */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/**
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * Copies a file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan *
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @returns VERR_ALREADY_EXISTS if the destination file exists.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @returns VBox Status code.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan *
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param pszSrc The path to the source file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param pszDst The path to the destination file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * This file will be created.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param fFlags Flags (RTFILECOPY_*).
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param pfnProgress Pointer to callback function for reporting progress.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param pvUser User argument to pass to pfnProgress along with the completion precentage.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan */
716c180559045549271833327182dc6a266134f1Nattuvetty BhavyanRTDECL(int) RTFileCopyEx(const char *pszSrc, const char *pszDst, uint32_t fFlags, PFNRTPROGRESS pfnProgress, void *pvUser);
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/**
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * Copies a file given the handles to both files and
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * provide progress callbacks.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns IPRT status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param FileSrc The source file. The file position is unaltered.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param FileDst The destination file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * On successful returns the file position is at the end of the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * On failures the file position and size is undefined.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pfnProgress Pointer to callback function for reporting progress.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pvUser User argument to pass to pfnProgress along with the completion precentage.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTDECL(int) RTFileCopyByHandlesEx(RTFILE FileSrc, RTFILE FileDst, PFNRTPROGRESS pfnProgress, void *pvUser);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Renames a file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Identical to RTPathRename except that it will ensure that the source is not a directory.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns IPRT status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_ALREADY_EXISTS if the destination file exists.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pszSrc The path to the source file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param pszDst The path to the destination file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * This file will be created.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param fRename See RTPathRename.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan */
716c180559045549271833327182dc6a266134f1Nattuvetty BhavyanRTDECL(int) RTFileRename(const char *pszSrc, const char *pszDst, unsigned fRename);
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** @name RTFileMove flags (bit masks).
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @{ */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan/** Replace destination file if present. */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan#define RTFILEMOVE_FLAGS_REPLACE 0x1
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @} */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Moves a file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * RTFileMove differs from RTFileRename in that it works across volumes.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns IPRT status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_ALREADY_EXISTS if the destination file exists.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pszSrc The path to the source file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pszDst The path to the destination file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * This file will be created.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param fMove A combination of the RTFILEMOVE_* flags.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTDECL(int) RTFileMove(const char *pszSrc, const char *pszDst, unsigned fMove);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @page pg_rt_filelock RT File locking API description
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * File locking general rules:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Region to lock or unlock can be located beyond the end of file, this can be used for
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * growing files.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Read (or Shared) locks can be acquired held by an unlimited number of processes at the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * same time, but a Write (or Exclusive) lock can only be acquired by one process, and
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * cannot coexist with a Shared lock. To acquire a Read lock, a process must wait until
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * there are no processes holding any Write locks. To acquire a Write lock, a process must
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * wait until there are no processes holding either kind of lock.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * By default, RTFileLock and RTFileChangeLock calls returns error immediately if the lock
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * can't be acquired due to conflict with other locks, however they can be called in wait mode.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Differences in implementation:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Win32, OS/2: Locking is mandatory, since locks are enforced by the operating system.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * I.e. when file region is locked in Read mode, any write in it will fail; in case of Write
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * lock - region can be readed and writed only by lock's owner.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Win32: File size change (RTFileSetSize) is not controlled by locking at all (!) in the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * operation system. Also see comments to RTFileChangeLock API call.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Linux/Posix: By default locks in Unixes are advisory. This means that cooperating processes
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * may use locks to coordonate access to a file between themselves, but programs are also free
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * to ignore locks and access the file in any way they choose to.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Additional reading:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * http://en.wikipedia.org/wiki/File_locking
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * http://unixhelp.ed.ac.uk/CGI/man-cgi?fcntl+2
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/lockfileex.asp
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @name Lock flags (bit masks).
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @{ */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Read access, can be shared with others. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_LOCK_READ 0x00
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Write access, one at a time. */
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan#define RTFILE_LOCK_WRITE 0x01
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Don't wait for other locks to be released. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_LOCK_IMMEDIATELY 0x00
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Wait till conflicting locks have been released. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_LOCK_WAIT 0x02
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** Valid flags mask */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define RTFILE_LOCK_MASK 0x03
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @} */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Locks a region of file for read (shared) or write (exclusive) access.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_FILE_LOCK_VIOLATION if lock can't be acquired.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param fLock Lock method and flags, see RTFILE_LOCK_* defines.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param offLock Offset of lock start.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param cbLock Length of region to lock, may overlap the end of file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Changes a lock type from read to write or from write to read.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * The region to type change must correspond exactly to an existing locked region.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If change can't be done due to locking conflict and non-blocking mode is used, error is
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * returned and lock keeps its state (see next warning).
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * WARNING: win32 implementation of this call is not atomic, it transforms to a pair of
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * calls RTFileUnlock and RTFileLock. Potentially the previously acquired lock can be
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * lost, i.e. function is called in non-blocking mode, previous lock is freed, new lock can't
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * be acquired, and old lock (previous state) can't be acquired back too. This situation
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * may occurs _only_ if the other process is acquiring a _write_ lock in blocking mode or
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * in race condition with the current call.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * In this very bad case special error code VERR_FILE_LOCK_LOST will be returned.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_FILE_NOT_LOCKED if region was not locked.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_FILE_LOCK_VIOLATION if lock type can't be changed, lock remains its type.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_FILE_LOCK_LOST if lock was lost, we haven't this lock anymore :(
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @param fLock Lock method and flags, see RTFILE_LOCK_* defines.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param offLock Offset of lock start.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param cbLock Length of region to lock, may overlap the end of file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileChangeLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * Unlocks previously locked region of file.
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * The region to unlock must correspond exactly to an existing locked region.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_FILE_NOT_LOCKED if region was not locked.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param offLock Offset of lock start.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param cbLock Length of region to unlock, may overlap the end of file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileUnlock(RTFILE File, int64_t offLock, uint64_t cbLock);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Query information about an open file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pObjInfo Object information structure to be filled on successful return.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param enmAdditionalAttribs Which set of additional attributes to request.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileQueryInfo(RTFILE File, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Changes one or more of the timestamps associated of file system object.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns VERR_NOT_SUPPORTED is returned if the operation isn't supported by the OS.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pAccessTime Pointer to the new access time. NULL if not to be changed.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pModificationTime Pointer to the new modifcation time. NULL if not to be changed.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pChangeTime Pointer to the new change time. NULL if not to be changed.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pBirthTime Pointer to the new time of birth. NULL if not to be changed.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark The file system might not implement all these time attributes,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * the API will ignore the ones which aren't supported.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark The file system might not implement the time resolution
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * employed by this interface, the time will be chopped to fit.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark The file system may update the change time even if it's
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * not specified.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte *
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * @remark POSIX can only set Access & Modification and will always set both.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte */
450396635f70344c58b6b1e4db38cf17ff34445cJohn ForteRTR3DECL(int) RTFileSetTimes(RTFILE File, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte/**
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Gets one or more of the timestamps associated of file system object.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte *
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * @returns iprt status code.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * @param File Handle to the file.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * @param pAccessTime Where to store the access time. NULL is ok.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * @param pModificationTime Where to store the modifcation time. NULL is ok.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * @param pChangeTime Where to store the change time. NULL is ok.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * @param pBirthTime Where to store the time of birth. NULL is ok.
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte *
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * @remark This is wrapper around RTFileQueryInfo() and exists to complement RTFileSetTimes().
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileGetTimes(RTFILE File, PRTTIMESPEC pAccessTime, PRTTIMESPEC pModificationTime,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto PRTTIMESPEC pChangeTime, PRTTIMESPEC pBirthTime);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Changes the mode flags of an open file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * The API requires at least one of the mode flag sets (Unix/Dos) to
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * be set. The type is ignored.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param fMode The new file mode, see @ref grp_rt_fs for details.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileSetMode(RTFILE File, RTFMODE fMode);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Gets the mode flags of an open file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pfMode Where to store the file mode, see @ref grp_rt_fs for details.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark This is wrapper around RTFileQueryInfo()
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * and exists to complement RTFileSetMode().
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileGetMode(RTFILE File, uint32_t *pfMode);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Changes the owner and/or group of an open file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param uid The new file owner user id. Use -1 (or ~0) to leave this unchanged.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param gid The new group id. Use -1 (or ~0) to leave this unchanged.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileSetOwner(RTFILE File, uint32_t uid, uint32_t gid);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Gets the owner and/or group of an open file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pUid Where to store the owner user id. NULL is ok.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pGid Where to store the group id. NULL is ok.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @remark This is wrapper around RTFileQueryInfo() and exists to complement RTFileGetOwner().
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileGetOwner(RTFILE File, uint32_t *pUid, uint32_t *pGid);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/**
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Executes an IOCTL on a file descriptor.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * This function is currently only available in L4 and posix environments.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Attemps at calling it from code shared with any other platforms will break things!
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * The rational for defining this API is to simplify L4 porting of audio drivers,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * and to remove some of the assumptions on RTFILE being a file descriptor on
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * platforms using the posix file implementation.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @returns iprt status code.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param File Handle to the file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param iRequest IOCTL request to carry out.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param pvData IOCTL data.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param cbData Size of the IOCTL data.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * @param piRet Return value of the IOCTL request.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoRTR3DECL(int) RTFileIoCtl(RTFILE File, int iRequest, void *pvData, unsigned cbData, int *piRet);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#endif /* IN_RING3 */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/** @} */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto__END_DECLS
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#endif
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto