Language:

The Free and Open Productivity Suite
Apache OpenOffice 4.1.4 released

Developer's Guide

API

SDK

Tips 'n' Tricks

Miscellaneous


Methods of Class File


File
File(
File & );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO NO NO

Summary
Copy constructor.

operator=
File & operator=(
File & );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO NO NO

Summary
Assginment operator.

File
File(
const ::rtl::OUString & ustrFileURL );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Constructor.
Parameters
ustrFileURL
        The full qualified URL of the file. Relative paths are not allowed.
    

~File
~File();

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Destructor

open
RC open(
sal_uInt32 uFlags );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Open a regular file.
Description
Open a file. Only regular files can be openend.
Parameters
uFlags
        Specifies the open mode.
        
        
Return
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()

close
RC close();

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Close an open file.
Return
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()

setPos
RC setPos(
sal_uInt32 uHow,
sal_Int64 uPos );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Set the internal position pointer of an open file.
Parameters
uHow
Distance to move the internal position pointer (from uPos).

uPos
Absolute position from the beginning of the file.

Return
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()

getPos
RC getPos(
sal_uInt64 & uPos );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Retrieve the current position of the internal pointer of an open file.
Parameters
uPos
On success receives the current position of the file pointer.

Return
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()

isEndOfFile
RC isEndOfFile(
sal_Bool * pIsEOF );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Test if the end of a file is reached.
Parameters
pIsEOF
Points to a variable that receives the end-of-file status.

Return
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()

setSize
RC setSize(
sal_uInt64 uSize );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Set the file size of an open file.
Description
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
        New size in bytes.
        
        
Return
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()

getSize
RC getSize(
sal_uInt64 & rSize );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Get the file size of an open file.
Description
Gets the file size of an open file. The position of the file pointer is not affeced by this function.
Parameters
rSize
        Current size in bytes.
        
        
Return
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()

read
RC read(
void * pBuffer,
sal_uInt64 uBytesRequested,
sal_uInt64 & rBytesRead );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Read a number of bytes from a file.
Description
Reads a number of bytes from a file. The internal file pointer is increased by the number of bytes read.
Parameters
pBuffer
        Points to a buffer which receives data. The buffer must be large enough    
        to hold uBytesRequested bytes.
        
        
uBytesRequested
        Number of bytes which should be retrieved.
        
        
rBytesRead
        On success the number of bytes which have actually been retrieved.
        
        
Return
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()

write
RC write(
const void * pBuffer,
sal_uInt64 uBytesToWrite,
sal_uInt64 & rBytesWritten );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Write a number of bytes to a file.
Description
Writes a number of bytes to a file. The internal file pointer is increased by the number of bytes read.
Parameters
pBuffer
    Points to a buffer which contains the data.
    
    
uBytesToWrite
    Number of bytes which should be written.
    
    
rBytesWritten
    On success the number of bytes which have actually been written.

    
Return
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()

readLine
RC readLine(
::rtl::ByteSequence & aSeq );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Read a line from a file.
Description
Reads a line from a file. The new line delimiter is NOT returned!
Parameters
aSeq
        A reference to a ::rtl::ByteSequence that will hold the line read on success.
        
        
Return
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()

sync
RC sync();

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Synchronize the memory representation of a file with that on the physical medium.
Description
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.
Return
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()

copy
static RC copy(
const ::rtl::OUString & ustrSourceFileURL,
const ::rtl::OUString & ustrDestFileURL );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO YES YES NO

Summary
Copy a file to a new destination.
Description
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
        Full qualified URL of the source file.
        
        
ustrDestFileURL
        Full qualified URL of the destination file. A directory is NOT a valid destination file!
        
        
Return
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()

move
static RC move(
const ::rtl::OUString & ustrSourceFileURL,
const ::rtl::OUString & ustrDestFileURL );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO YES YES NO

Summary
Move a file or directory to a new destination or renames it.
Description
Moves a file or directory to a new destination or renames it. File time and attributes are preserved.
Parameters
ustrSourceFileURL
        Full qualified URL of the source file.
        
        
ustrDestFileURL
        Full qualified URL of the destination file. An existing directory is NOT a valid destination !
        
        
Return
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()

remove
static RC remove(
const ::rtl::OUString & ustrFileURL );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO YES YES NO

Summary
Remove a regular file.
Parameters
ustrFileURL
        Full qualified URL of the file to remove.
        
        
Return
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()

setAttributes
static RC setAttributes(
const ::rtl::OUString & ustrFileURL,
sal_uInt64 uAttributes );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO YES YES NO

Summary
Set file attributes.
Parameters
ustrFileURL
        The full qualified file URL.
        
        
uAttributes
        Attributes of the file to be set.

        
Return
E_None on success E_INVAL the format of the parameters was not valid
See Also
FileStatus

setTime
static RC setTime(
const ::rtl::OUString & ustrFileURL,
const TimeValue & rCreationTime,
const TimeValue & rLastAccessTime,
const TimeValue & rLastWriteTime );

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO YES YES NO

Summary
Set the file time.
Parameters
ustrFileURL
        The full qualified URL of the file.
        
        
rCreationTime
        Creation time of the given file.
        
        
rLastAccessTime
        Time of the last access of the given file.
        
        
rLastWriteTime
        Time of the last modifying of the given file.

        
Return
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

Top of Page

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache and the Apache feather logo are trademarks of The Apache Software Foundation. OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.