UDK 3.2.7 C/C++ API Reference
Public Member Functions | Static Public Member Functions | Friends
osl::File Class Reference

The file class object provides access to file contents and attributes. More...

#include <file.hxx>

Inheritance diagram for osl::File:
osl::FileBase

List of all members.

Public Member Functions

 File (const ::rtl::OUString &ustrFileURL)
 Constructor.
 ~File ()
 Destructor.
RC open (sal_uInt32 uFlags)
 Open a regular file.
RC close ()
 Close an open file.
RC setPos (sal_uInt32 uHow, sal_Int64 uPos) SAL_WARN_UNUSED_RESULT
 Set the internal position pointer of an open file.
RC getPos (sal_uInt64 &uPos)
 Retrieve the current position of the internal pointer of an open file.
RC isEndOfFile (sal_Bool *pIsEOF)
 Test if the end of a file is reached.
RC setSize (sal_uInt64 uSize)
 Set the file size of an open file.
RC getSize (sal_uInt64 &rSize)
 Get the file size of an open file.
RC read (void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
 Read a number of bytes from a file.
RC write (const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &rBytesWritten)
 Write a number of bytes to a file.
RC readLine (::rtl::ByteSequence &aSeq)
 Read a line from a file.
RC sync () const
 Synchronize the memory representation of a file with that on the physical medium.

Static Public Member Functions

static RC copy (const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
 Copy a file to a new destination.
static RC move (const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
 Move a file or directory to a new destination or renames it.
static RC remove (const ::rtl::OUString &ustrFileURL)
 Remove a regular file.
static RC setAttributes (const ::rtl::OUString &ustrFileURL, sal_uInt64 uAttributes)
 Set file attributes.
static RC setTime (const ::rtl::OUString &ustrFileURL, const TimeValue &rCreationTime, const TimeValue &rLastAccessTime, const TimeValue &rLastWriteTime)
 Set the file time.

Friends

class DirectoryItem

Detailed Description

The file class object provides access to file contents and attributes.

See also:
Directory
DirectoryItem

Constructor & Destructor Documentation

osl::File::File ( const ::rtl::OUString ustrFileURL) [inline]

Constructor.

Parameters:
ustrFileURL[in] The full qualified URL of the file. Relative paths are not allowed.
osl::File::~File ( ) [inline]

Destructor.


Member Function Documentation

RC osl::File::close ( ) [inline]

Close an open file.

Returns:
E_None on success E_INVAL the format of the parameters was not valid E_BADF Bad file E_INTR function call was interrupted E_NOLINK link has been severed E_NOSPC no space left on device E_IO on I/O errors
See also:
open()
static RC osl::File::copy ( const ::rtl::OUString ustrSourceFileURL,
const ::rtl::OUString ustrDestFileURL 
) [inline, static]

Copy a file to a new destination.

Copies a file to a new destination. Copies only files not directories. No assumptions should be made about preserving attributes or file time.

Parameters:
ustrSourceFileURL[in] Full qualified URL of the source file.
ustrDestFileURL[in] Full qualified URL of the destination file. A directory is NOT a valid destination file!
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_NOMEM not enough memory for allocating structures E_ACCES permission denied E_PERM operation not permitted E_NAMETOOLONG file name too long E_NOENT no such file or directory E_ISDIR is a directory E_ROFS read-only file system
See also:
move()
remove()
RC osl::File::getPos ( sal_uInt64 &  uPos) [inline]

Retrieve the current position of the internal pointer of an open file.

Parameters:
uPos[out] On success receives the current position of the file pointer.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
See also:
open()
setPos()
read()
write()
RC osl::File::getSize ( sal_uInt64 &  rSize) [inline]

Get the file size of an open file.

Gets the file size of an open file. The position of the file pointer is not affeced by this function.

Parameters:
rSize[out] Current size in bytes.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
See also:
open()
setPos()
getSize()
setSize()
getStatus()
RC osl::File::isEndOfFile ( sal_Bool pIsEOF) [inline]

Test if the end of a file is reached.

Parameters:
pIsEOF[out] Points to a variable that receives the end-of-file status.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_INTR function call was interrupted E_IO on I/O errors E_ISDIR is a directory E_BADF bad file E_FAULT bad address E_AGAIN operation would block E_NOLINK link has been severed
See also:
open()
read()
readLine()
setPos()
static RC osl::File::move ( const ::rtl::OUString ustrSourceFileURL,
const ::rtl::OUString ustrDestFileURL 
) [inline, static]

Move a file or directory to a new destination or renames it.

Moves a file or directory to a new destination or renames it. File time and attributes are preserved.

Parameters:
ustrSourceFileURL[in] Full qualified URL of the source file.
ustrDestFileURL[in] Full qualified URL of the destination file. An existing directory is NOT a valid destination !
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_NOMEM not enough memory for allocating structures E_ACCES permission denied E_PERM operation not permitted E_NAMETOOLONG file name too long E_NOENT no such file or directory E_ROFS read-only file system
See also:
copy()
RC osl::File::open ( sal_uInt32  uFlags) [inline]

Open a regular file.

Open a file. Only regular files can be openend.

Parameters:
uFlags[in] Specifies the open mode.
Returns:
E_None on success E_NOMEM not enough memory for allocating structures E_INVAL the format of the parameters was not valid E_NAMETOOLONG pathname was too long E_NOENT no such file or directory E_ACCES permission denied E_AGAIN a write lock could not be established E_NOTDIR not a directory E_NXIO no such device or address E_NODEV no such device E_ROFS read-only file system E_TXTBSY text file busy E_FAULT bad address E_LOOP too many symbolic links encountered E_NOSPC no space left on device E_ISDIR is a directory E_MFILE too many open files used by the process E_NFILE too many open files in the system E_DQUOT quota exceeded E_EXIST file exists E_INTR function call was interrupted E_IO on I/O errors E_MULTIHOP multihop attempted E_NOLINK link has been severed E_EOVERFLOW value too large for defined data type
See also:
close()
setPos()
getPos()
read()
write()
getSize()
setSize()
RC osl::File::read ( void *  pBuffer,
sal_uInt64  uBytesRequested,
sal_uInt64 &  rBytesRead 
) [inline]

Read a number of bytes from a file.

Reads a number of bytes from a file. The internal file pointer is increased by the number of bytes read.

Parameters:
pBuffer[out] Points to a buffer which receives data. The buffer must be large enough to hold uBytesRequested bytes.
uBytesRequested[in] Number of bytes which should be retrieved.
rBytesRead[out] On success the number of bytes which have actually been retrieved.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_INTR function call was interrupted E_IO on I/O errors E_ISDIR is a directory E_BADF bad file E_FAULT bad address E_AGAIN operation would block E_NOLINK link has been severed
See also:
open()
write()
readLine()
setPos()
RC osl::File::readLine ( ::rtl::ByteSequence aSeq) [inline]

Read a line from a file.

Reads a line from a file. The new line delimiter is NOT returned!

Parameters:
aSeq[in/out] A reference to a rtl::ByteSequence that will hold the line read on success.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_INTR function call was interrupted E_IO on I/O errors E_ISDIR is a directory E_BADF bad file E_FAULT bad address E_AGAIN operation would block E_NOLINK link has been severed
See also:
open()
read()
write()
setPos()
static RC osl::File::remove ( const ::rtl::OUString ustrFileURL) [inline, static]

Remove a regular file.

Parameters:
ustrFileURL[in] Full qualified URL of the file to remove.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_NOMEM not enough memory for allocating structures E_ACCES permission denied E_PERM operation not permitted E_NAMETOOLONG file name too long E_NOENT no such file or directory E_ISDIR is a directory E_ROFS read-only file system E_FAULT bad address E_LOOP too many symbolic links encountered E_IO on I/O errors E_BUSY device or resource busy E_INTR function call was interrupted E_LOOP too many symbolic links encountered E_MULTIHOP multihop attempted E_NOLINK link has been severed E_TXTBSY text file busy
See also:
open()
static RC osl::File::setAttributes ( const ::rtl::OUString ustrFileURL,
sal_uInt64  uAttributes 
) [inline, static]

Set file attributes.

Parameters:
ustrFileURL[in] The full qualified file URL.
uAttributes[in] Attributes of the file to be set.
Returns:
E_None on success E_INVAL the format of the parameters was not valid
See also:
FileStatus
RC osl::File::setPos ( sal_uInt32  uHow,
sal_Int64  uPos 
) [inline]

Set the internal position pointer of an open file.

Parameters:
uHow[in] Distance to move the internal position pointer (from uPos).
uPos[in] Absolute position from the beginning of the file.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
See also:
open()
getPos()
RC osl::File::setSize ( sal_uInt64  uSize) [inline]

Set the file size of an open file.

Sets the file size of an open file. The file can be truncated or enlarged by the function. The position of the file pointer is not affeced by this function.

Parameters:
uSize[in] New size in bytes.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
See also:
open()
setPos()
getStatus()
static RC osl::File::setTime ( const ::rtl::OUString ustrFileURL,
const TimeValue rCreationTime,
const TimeValue rLastAccessTime,
const TimeValue rLastWriteTime 
) [inline, static]

Set the file time.

Parameters:
ustrFileURL[in] The full qualified URL of the file.
rCreationTime[in] Creation time of the given file.
rLastAccessTime[in] Time of the last access of the given file.
rLastWriteTime[in] Time of the last modifying of the given file.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_NOENT no such file or directory not found
See also:
FileStatus
RC osl::File::sync ( ) const [inline]

Synchronize the memory representation of a file with that on the physical medium.

The function ensures that all modified data and attributes of the file associated with the given file handle have been written to the physical medium. In case the hard disk has a write cache enabled, the data may not really be on permanent storage when osl_syncFile returns.

Returns:
E_None
On success
E_INVAL
The value of the input parameter is invalid

In addition to these error codes others may occur as well, for instance:

E_BADF The file is not open for writing

E_IO An I/O error occurred

E_NOSPC There is no enough space on the target device

E_ROFS The file is located on a read only file system

E_TIMEDOUT A remote connection timed out. This may happen when a file is on a remote location

See also:
osl_syncFile()
open()
write()
RC osl::File::write ( const void *  pBuffer,
sal_uInt64  uBytesToWrite,
sal_uInt64 &  rBytesWritten 
) [inline]

Write a number of bytes to a file.

Writes a number of bytes to a file. The internal file pointer is increased by the number of bytes read.

Parameters:
pBuffer[in] Points to a buffer which contains the data.
uBytesToWrite[in] Number of bytes which should be written.
rBytesWritten[out] On success the number of bytes which have actually been written.
Returns:
E_None on success E_INVAL the format of the parameters was not valid E_FBIG file too large E_DQUOT quota exceeded E_AGAIN operation would block E_BADF bad file E_FAULT bad address E_INTR function call was interrupted E_IO on I/O errosr E_NOLCK no record locks available E_NOLINK link has been severed E_NOSPC no space left on device E_NXIO no such device or address
See also:
open()
read()
setPos()

Friends And Related Function Documentation

friend class DirectoryItem [friend]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines