ACE_FILE Class Reference

Defines the core methods of the ACE_FILE abstraction. More...

#include <FILE.h>

Inheritance diagram for ACE_FILE:

Inheritance graph
[legend]
Collaboration diagram for ACE_FILE:

Collaboration graph
[legend]
List of all members.

Public Member Functions

int close (void)
int remove (void)
 Close and remove the ACE_FILE from the file system.
int unlink (void)
int get_info (ACE_FILE_Info *finfo)
 Get information on this ACE_FILE.
int get_info (ACE_FILE_Info &finfo)
 Get information on this ACE_FILE.
int truncate (ACE_OFF_T length)
 Set filesize to length byte.
ACE_OFF_T seek (ACE_OFF_T offset, int whence=SEEK_CUR)
ACE_OFF_T tell (void)
 Return an offset for the file handle.
int disable (int signum) const
int get_local_addr (ACE_Addr &) const
int get_remote_addr (ACE_Addr &) const
 Return the same thing as get_local_addr().
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Protected Member Functions

 ACE_FILE (void)

Protected Attributes

ACE_FILE_Addr addr_
 File we are "connected" with...

Detailed Description

Defines the core methods of the ACE_FILE abstraction.

Definition at line 63 of file FILE.h.


Constructor & Destructor Documentation

ACE_FILE::ACE_FILE ( void   )  [protected]

Ensure that this class is only created by the ACE_FILE_Connector.

Definition at line 32 of file FILE.cpp.

References ACE_TRACE.

00033 {
00034   ACE_TRACE ("ACE_FILE::ACE_FILE");
00035 }


Member Function Documentation

int ACE_FILE::close ( void   ) 

Close the ACE_FILE handle without removing the ACE_FILE from the file system.

Definition at line 40 of file FILE.cpp.

References ACE_TRACE, ACE_OS::close(), and ACE_IO_SAP::set_handle().

Referenced by remove().

00041 {
00042   ACE_TRACE ("ACE_FILE::close");
00043   int result = 0;
00044 
00045   if (this->get_handle () != ACE_INVALID_HANDLE)
00046     {
00047       result = ACE_OS::close (this->get_handle ());
00048       this->set_handle (ACE_INVALID_HANDLE);
00049     }
00050   return result;
00051 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_FILE::disable ( int  signum  )  const

Disable signal signum This is here to prevent Win32 from disabling SPIPE using socket calls

Reimplemented from ACE_IO_SAP.

Definition at line 8 of file FILE.inl.

References ACE_IO_SAP::disable().

00009 {
00010 #if defined (ACE_WIN32)
00011   ACE_UNUSED_ARG (signum) ;
00012   return 0 ;
00013 #else  /* ACE_WIN32 */
00014   return ACE_IO_SAP::disable (signum) ;
00015 #endif /* ACE_WIN32 */
00016 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_FILE::dump ( void   )  const

Dump the state of an object.

Reimplemented from ACE_IO_SAP.

Reimplemented in ACE_FILE_IO.

Definition at line 22 of file FILE.cpp.

References ACE_TRACE, and ACE_IO_SAP::dump().

00023 {
00024 #if defined (ACE_HAS_DUMP)
00025   ACE_TRACE ("ACE_FILE::dump");
00026   ACE_IO_SAP::dump ();
00027 #endif /* ACE_HAS_DUMP */
00028 }

int ACE_FILE::get_info ( ACE_FILE_Info finfo  ) 

Get information on this ACE_FILE.

Definition at line 72 of file FILE.cpp.

References ACE_TRACE, and get_info().

00073 {
00074   ACE_TRACE ("ACE_FILE::get_info");
00075 
00076   return this->get_info (&finfo);
00077 }

int ACE_FILE::get_info ( ACE_FILE_Info finfo  ) 

Get information on this ACE_FILE.

Definition at line 54 of file FILE.cpp.

References ACE_TRACE, ACE_OS::fstat(), ACE_FILE_Info::mode_, ACE_FILE_Info::nlink_, and ACE_FILE_Info::size_.

Referenced by get_info().

00055 {
00056   ACE_TRACE ("ACE_FILE::get_info");
00057   ACE_stat filestatus;
00058 
00059   int const result = ACE_OS::fstat (this->get_handle (), &filestatus);
00060 
00061   if (result == 0)
00062     {
00063       finfo->mode_ = filestatus.st_mode;
00064       finfo->nlink_ = filestatus.st_nlink;
00065       finfo->size_ = filestatus.st_size;
00066     }
00067 
00068   return result;
00069 }

int ACE_FILE::get_local_addr ( ACE_Addr  )  const

Return the local endpoint address in the referenced ACE_Addr. Returns 0 if successful, else -1.

Definition at line 102 of file FILE.cpp.

References ACE_TRACE, and addr_.

Referenced by get_remote_addr().

00103 {
00104   ACE_TRACE ("ACE_FILE::get_local_addr");
00105 
00106   // Perform the downcast since <addr> had better be an
00107   // <ACE_FILE_Addr>.
00108   ACE_FILE_Addr *file_addr =
00109     dynamic_cast<ACE_FILE_Addr *> (&addr);
00110 
00111   if (file_addr == 0)
00112     return -1;
00113   else
00114     {
00115       *file_addr = this->addr_;
00116       return 0;
00117     }
00118 }

int ACE_FILE::get_remote_addr ( ACE_Addr  )  const

Return the same thing as get_local_addr().

Definition at line 123 of file FILE.cpp.

References ACE_TRACE, and get_local_addr().

00124 {
00125   ACE_TRACE ("ACE_FILE::get_remote_addr");
00126 
00127   return this->get_local_addr (addr);
00128 }

int ACE_FILE::remove ( void   ) 

Close and remove the ACE_FILE from the file system.

Definition at line 131 of file FILE.cpp.

References ACE_TRACE, close(), and ACE_OS::unlink().

00132 {
00133   ACE_TRACE ("ACE_FILE::remove");
00134 
00135   this->close ();
00136   return ACE_OS::unlink (this->addr_.get_path_name ());
00137 }

ACE_OFF_T ACE_FILE::seek ( ACE_OFF_T  offset,
int  whence = SEEK_CUR 
)

Sets the file pointer as follows: o If <whence> is <SEEK_SET>, the pointer is set to offset bytes.

o If <whence> is <SEEK_CUR>, the pointer is set to its current location plus offset.

o If <whence> is <SEEK_END>, the pointer is set to the size of the file plus offset.

Definition at line 87 of file FILE.cpp.

References ACE_OS::lseek().

00088 {
00089   return ACE_OS::lseek (this->get_handle (), offset, startpos);
00090 }

ACE_OFF_T ACE_FILE::tell ( void   ) 

Return an offset for the file handle.

Definition at line 93 of file FILE.cpp.

References ACE_TRACE, and ACE_OS::lseek().

00094 {
00095   ACE_TRACE ("ACE_FILE::tell");
00096   return ACE_OS::lseek (this->get_handle (), 0, SEEK_CUR);
00097 }

int ACE_FILE::truncate ( ACE_OFF_T  length  ) 

Set filesize to length byte.

Definition at line 80 of file FILE.cpp.

References ACE_TRACE, and ACE_OS::ftruncate().

00081 {
00082   ACE_TRACE ("ACE_FILE::truncate");
00083   return ACE_OS::ftruncate (this->get_handle (), length);
00084 }

int ACE_FILE::unlink ( void   ) 

Remove the ACE_FILE from the file system without closing the ACE_FILE handle.

Definition at line 140 of file FILE.cpp.

References ACE_TRACE, and ACE_OS::unlink().

00141 {
00142   ACE_TRACE ("ACE_FILE::unlink");
00143 
00144   return ACE_OS::unlink (this->addr_.get_path_name ());
00145 }


Member Data Documentation

ACE_FILE::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Reimplemented from ACE_IO_SAP.

Reimplemented in ACE_FILE_IO.

Definition at line 121 of file FILE.h.

ACE_FILE_Addr ACE_FILE::addr_ [protected]

File we are "connected" with...

Definition at line 129 of file FILE.h.

Referenced by ACE_FILE_Connector::connect(), and get_local_addr().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:07 2010 for ACE by  doxygen 1.4.7