OCC Main Page | FoundationClasses | Toolkits | Packages | Class Hierarchy | Data Structures | File List | Data Fields | Globals

FoundationClasses
TKernel
OSD


OSD_File Class Reference

Basic tools to manage files
Warning: 'ProgramError' is raised when somebody wants to use the methods
Read, Write, Seek, Close when File is not open.
.

#include <OSD_File.hxx>

Inheritance diagram for OSD_File:

Inheritance graph
[legend]

Public Member Functions

void * operator new (size_t, void *anAddress)
void * operator new (size_t size)
void operator delete (void *anAddress)
Standard_EXPORT OSD_File ()
 Creates File object.
.
Standard_EXPORT OSD_File (const OSD_Path &Name)
 Instantiates the object file, storing its name
.
Standard_EXPORT void Build (const OSD_OpenMode Mode, const OSD_Protection &Protect)
 CREATES a file if it doesn't already exists or empties
an existing file.
After 'Build', the file is open.
If no name was given, ProgramError is raised.
.
Standard_EXPORT void Open (const OSD_OpenMode Mode, const OSD_Protection &Protect)
 Opens a File with specific attributes
This works only on already existing file.
If no name was given, ProgramError is raised.
.
Standard_EXPORT void Append (const OSD_OpenMode Mode, const OSD_Protection &Protect)
 Appends data to an existing file.
If file doesn't exist, creates it first.
After 'Append', the file is open.
If no name was given, ProgramError is raised.
.
Standard_EXPORT void Read (TCollection_AsciiString &Buffer, const Standard_Integer Nbyte)
 Attempts to read Nbyte bytes from the file associated with
the object file.
Upon successful completion, Read returns the number of
bytes actually read and placed in the Buffer. This number
may be less than Nbyte if the number of bytes left in the file
is less than Nbyte bytes. In this case only number of read
bytes will be placed in the buffer.
.
Standard_EXPORT void ReadLine (TCollection_AsciiString &Buffer, const Standard_Integer NByte, Standard_Integer &NbyteRead)
 Reads bytes from the data pointed to by the object file
into the buffer <buffer>.
Data is read until <NByte-1> bytes have been read,
until a newline character is read and transferred into
<buffer>, or until an EOF (End-of-File) condition is
encountered.
Upon successful completion, Read returns the number of
bytes actually read into <nbyteread> and placed into the
Buffer <buffer>.
.
Standard_EXPORT void Read (Standard_Address &Buffer, const Standard_Integer Nbyte, Standard_Integer &Readbyte)
 Attempts to read Nbyte bytes from the files associated with
the object File.
Upon successful completion, Read returns the number of
bytes actually read and placed in the Buffer. This number
may be less than Nbyte if the number of bytes left in the file
is less than Nbyte bytes. For this reason the output
parameter Readbyte will contain the number of read bytes.
.
Standard_EXPORT void Write (const TCollection_AsciiString &Buffer, const Standard_Integer Nbyte)
 Attempts to write Nbyte bytes from the AsciiString to the file
associated to the object File.
.
Standard_EXPORT void Write (const Standard_Address Buffer, const Standard_Integer Nbyte)
 Attempts to write Nbyte bytes from the buffer pointed
to by Buffer to the file associated to the object File.
.
Standard_EXPORT void Seek (const Standard_Integer Offset, const OSD_FromWhere Whence)
 Sets the seek pointer associated with the open file
.
Standard_EXPORT void Close ()
 Closes the file (and deletes a descriptor)
.
Standard_EXPORT Standard_Boolean IsAtEnd ()
 Returns TRUE if the seek pointer is at end of file.
.
Standard_EXPORT OSD_KindFile KindOfFile () const
 Returns the kind of file. A file can be a
file, a directory or a link.
.
Standard_EXPORT void SetLock (const OSD_LockType Lock)
 Locks current file
.
Standard_EXPORT void UnLock ()
 Unlocks current file
.
Standard_EXPORT OSD_LockType GetLock ()
 Returns the current lock state
.
Standard_EXPORT Standard_Boolean IsLocked ()
 Returns TRUE if this file is locked.
.
Standard_EXPORT Standard_Integer Size ()
 Returns actual number of bytes of <me>.
.
Standard_EXPORT void Print (const OSD_Printer &WhichPrinter)
 Prints a file on selected printer.
.
Standard_EXPORT Standard_Boolean IsOpen () const
 Returns TRUE if <me> is open.
.
Standard_EXPORT Standard_Boolean IsReadable ()
 returns TRUE if the file exists and if the user
has the autorization to read it.

Standard_EXPORT Standard_Boolean IsWriteable ()
 returns TRUE if the file can be read and overwritten.

Standard_EXPORT Standard_Boolean IsExecutable ()
 returns TRUE if the file can be executed.

Standard_EXPORT Standard_Boolean ReadLastLine (TCollection_AsciiString &aLine, const Standard_Integer aDelay, const Standard_Integer aNbTries)
 Enables to emulate unix "tail -f" command.
If a line is available in the file <me> returns it.
Otherwise attemps to read again aNbTries times in the file
waiting aDelay seconds between each read.
If meanwhile the file increases returns the next line, otherwise
returns FALSE.
.
Standard_EXPORT Standard_Boolean Edit ()
 find an editor on the system and edit the given file


Static Public Member Functions

static Standard_EXPORT OSD_File BuildTemporary ()
 Makes a temporary File
This returned file is already open !
This file is non-persistent and will be automatically
removed when its process finishes.
.

Protected Attributes

Standard_Integer myIO
Standard_Address myFILE

Private Attributes

Standard_Boolean ImperativeFlag
OSD_LockType myLock
OSD_OpenMode myMode
Standard_CString myBuffer
Standard_CString myCurrPtr
Standard_CString myEndPtr

Constructor & Destructor Documentation

Standard_EXPORT OSD_File::OSD_File  ) 
 

Standard_EXPORT OSD_File::OSD_File const OSD_Path Name  ) 
 


Member Function Documentation

Standard_EXPORT void OSD_File::Append const OSD_OpenMode  Mode,
const OSD_Protection Protect
 

Standard_EXPORT void OSD_File::Build const OSD_OpenMode  Mode,
const OSD_Protection Protect
 

static Standard_EXPORT OSD_File OSD_File::BuildTemporary  )  [static]
 

Standard_EXPORT void OSD_File::Close  ) 
 

Standard_EXPORT Standard_Boolean OSD_File::Edit  ) 
 

Standard_EXPORT OSD_LockType OSD_File::GetLock  ) 
 

Standard_EXPORT Standard_Boolean OSD_File::IsAtEnd  ) 
 

Standard_EXPORT Standard_Boolean OSD_File::IsExecutable  ) 
 

Standard_EXPORT Standard_Boolean OSD_File::IsLocked  ) 
 

Standard_EXPORT Standard_Boolean OSD_File::IsOpen  )  const
 

Standard_EXPORT Standard_Boolean OSD_File::IsReadable  ) 
 

Standard_EXPORT Standard_Boolean OSD_File::IsWriteable  ) 
 

Standard_EXPORT OSD_KindFile OSD_File::KindOfFile  )  const
 

Standard_EXPORT void OSD_File::Open const OSD_OpenMode  Mode,
const OSD_Protection Protect
 

void OSD_File::operator delete void *  anAddress  )  [inline]
 

Reimplemented from OSD_FileNode.

void* OSD_File::operator new size_t  size  )  [inline]
 

Reimplemented from OSD_FileNode.

void* OSD_File::operator new size_t  ,
void *  anAddress
[inline]
 

Reimplemented from OSD_FileNode.

Standard_EXPORT void OSD_File::Print const OSD_Printer WhichPrinter  ) 
 

Standard_EXPORT void OSD_File::Read Standard_Address Buffer,
const Standard_Integer  Nbyte,
Standard_Integer Readbyte
 

Standard_EXPORT void OSD_File::Read TCollection_AsciiString Buffer,
const Standard_Integer  Nbyte
 

Standard_EXPORT Standard_Boolean OSD_File::ReadLastLine TCollection_AsciiString aLine,
const Standard_Integer  aDelay,
const Standard_Integer  aNbTries
 

Standard_EXPORT void OSD_File::ReadLine TCollection_AsciiString Buffer,
const Standard_Integer  NByte,
Standard_Integer NbyteRead
 

Standard_EXPORT void OSD_File::Seek const Standard_Integer  Offset,
const OSD_FromWhere  Whence
 

Standard_EXPORT void OSD_File::SetLock const OSD_LockType  Lock  ) 
 

Standard_EXPORT Standard_Integer OSD_File::Size  ) 
 

Standard_EXPORT void OSD_File::UnLock  ) 
 

Standard_EXPORT void OSD_File::Write const Standard_Address  Buffer,
const Standard_Integer  Nbyte
 

Standard_EXPORT void OSD_File::Write const TCollection_AsciiString Buffer,
const Standard_Integer  Nbyte
 


Field Documentation

Standard_Boolean OSD_File::ImperativeFlag [private]
 

Standard_CString OSD_File::myBuffer [private]
 

Standard_CString OSD_File::myCurrPtr [private]
 

Standard_CString OSD_File::myEndPtr [private]
 

Standard_Address OSD_File::myFILE [protected]
 

Standard_Integer OSD_File::myIO [protected]
 

OSD_LockType OSD_File::myLock [private]
 

OSD_OpenMode OSD_File::myMode [private]
 


The documentation for this class was generated from the following file:
Generated on Mon Aug 25 13:13:08 2008 for OpenCASCADE by  doxygen 1.4.1