Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

FILE.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // FILE.cpp
00003 // $Id: FILE.cpp,v 1.1.1.3.40.2 2003/04/16 16:41:14 taoadmin Exp $
00004 
00005 /* Defines the member functions for the base class of the ACE_IO_SAP
00006    ACE_FILE abstraction. */
00007 
00008 #include "ace/FILE.h"
00009 
00010 #if defined (ACE_LACKS_INLINE_FUNCTIONS)
00011 #include "ace/FILE.i"
00012 #endif
00013 
00014 ACE_RCSID(ace, FILE, "$Id: FILE.cpp,v 1.1.1.3.40.2 2003/04/16 16:41:14 taoadmin Exp $")
00015 
00016 ACE_ALLOC_HOOK_DEFINE(ACE_FILE)
00017 
00018 void
00019 ACE_FILE::dump (void) const
00020 {
00021   ACE_TRACE ("ACE_FILE::dump");
00022   ACE_IO_SAP::dump ();
00023 }
00024 
00025 // This is the do-nothing constructor.
00026 
00027 ACE_FILE::ACE_FILE (void)
00028 {
00029   ACE_TRACE ("ACE_FILE::ACE_FILE");
00030 }
00031 
00032 // Close the file
00033 
00034 int
00035 ACE_FILE::close (void)
00036 {
00037   ACE_TRACE ("ACE_FILE::close");
00038   int result = 0;
00039 
00040   if (this->get_handle () != ACE_INVALID_HANDLE)
00041     {
00042       result = ACE_OS::close (this->get_handle ());
00043       this->set_handle (ACE_INVALID_HANDLE);
00044     }
00045   return result;
00046 }
00047 
00048 int
00049 ACE_FILE::get_info (ACE_FILE_Info *finfo)
00050 {
00051   ACE_TRACE ("ACE_FILE::get_info");
00052   ACE_stat filestatus;
00053 
00054   int result = ACE_OS::fstat (this->get_handle (),
00055                               &filestatus);
00056 
00057   if (result == 0)
00058     {
00059       finfo->mode_ = filestatus.st_mode;
00060       finfo->nlink_ = filestatus.st_nlink;
00061       finfo->size_ = filestatus.st_size;
00062     }
00063 
00064   return result;
00065 }
00066 
00067 int
00068 ACE_FILE::get_info (ACE_FILE_Info &finfo)
00069 {
00070   ACE_TRACE ("ACE_FILE::get_info");
00071 
00072   return this->get_info (&finfo);
00073 }
00074 
00075 int
00076 ACE_FILE::truncate (off_t length)
00077 {
00078   ACE_TRACE ("ACE_FILE::truncate");
00079   return ACE_OS::ftruncate (this->get_handle(), length);
00080 }
00081 
00082 off_t
00083 ACE_FILE::seek (off_t offset, int startpos)
00084 {
00085   return ACE_OS::lseek (this->get_handle (),
00086                         offset,
00087                         startpos);
00088 }
00089 
00090 off_t
00091 ACE_FILE::position (long offset, int startpos)
00092 {
00093   ACE_TRACE ("ACE_FILE::position");
00094   return this->seek (offset, startpos);
00095 }
00096 
00097 off_t
00098 ACE_FILE::tell (void)
00099 {
00100   ACE_TRACE ("ACE_FILE::tell");
00101   return ACE_OS::lseek (this->get_handle (), 0, SEEK_CUR);
00102 }
00103 
00104 off_t
00105 ACE_FILE::position (void)
00106 {
00107   ACE_TRACE ("ACE_FILE::position");
00108   return this->tell ();
00109 }
00110 
00111 // Return the local endpoint address.
00112 
00113 int
00114 ACE_FILE::get_local_addr (ACE_Addr &addr) const
00115 {
00116   ACE_TRACE ("ACE_FILE::get_local_addr");
00117 
00118   // Perform the downcast since <addr> had better be an
00119   // <ACE_FILE_Addr>.
00120   ACE_FILE_Addr *file_addr =
00121     ACE_dynamic_cast (ACE_FILE_Addr *, &addr);
00122 
00123   if (file_addr == 0)
00124     return -1;
00125   else
00126     {
00127       *file_addr = this->addr_;
00128       return 0;
00129     }
00130 }
00131 
00132 // Return the same result as <get_local_addr>.
00133 
00134 int
00135 ACE_FILE::get_remote_addr (ACE_Addr &addr) const
00136 {
00137   ACE_TRACE ("ACE_FILE::get_remote_addr");
00138 
00139   return this->get_local_addr (addr);
00140 }
00141 
00142 int
00143 ACE_FILE::remove (void)
00144 {
00145   ACE_TRACE ("ACE_FILE::remove");
00146 
00147   this->close ();
00148   return ACE_OS::unlink (this->addr_.get_path_name ());
00149 }
00150 
00151 int
00152 ACE_FILE::unlink (void)
00153 {
00154   ACE_TRACE ("ACE_FILE::unlink");
00155 
00156   return ACE_OS::unlink (this->addr_.get_path_name ());
00157 }

Generated on Mon Jun 16 11:19:40 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002