Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / FILE.cpp
blob9cf86ef6228c233644dec20c3261910ade2ac06f
1 /* Defines the member functions for the base class of the ACE_IO_SAP
2 ACE_FILE abstraction. */
4 #include "ace/FILE.h"
6 #include "ace/OS_NS_unistd.h"
7 #include "ace/OS_NS_sys_stat.h"
9 #if defined (ACE_HAS_ALLOC_HOOKS)
10 # include "ace/Malloc_Base.h"
11 #endif /* ACE_HAS_ALLOC_HOOKS */
13 #if !defined (__ACE_INLINE__)
14 #include "ace/FILE.inl"
15 #endif /* __ACE_INLINE__ */
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
19 ACE_ALLOC_HOOK_DEFINE(ACE_FILE)
21 void
22 ACE_FILE::dump () const
24 #if defined (ACE_HAS_DUMP)
25 ACE_TRACE ("ACE_FILE::dump");
26 ACE_IO_SAP::dump ();
27 #endif /* ACE_HAS_DUMP */
30 // This is the do-nothing constructor.
32 ACE_FILE::ACE_FILE ()
34 ACE_TRACE ("ACE_FILE::ACE_FILE");
37 // Close the file
39 int
40 ACE_FILE::close ()
42 ACE_TRACE ("ACE_FILE::close");
43 int result = 0;
45 if (this->get_handle () != ACE_INVALID_HANDLE)
47 result = ACE_OS::close (this->get_handle ());
48 this->set_handle (ACE_INVALID_HANDLE);
50 return result;
53 int
54 ACE_FILE::get_info (ACE_FILE_Info *finfo)
56 ACE_TRACE ("ACE_FILE::get_info");
57 ACE_stat filestatus;
59 int const result = ACE_OS::fstat (this->get_handle (), &filestatus);
61 if (result == 0)
63 finfo->mode_ = filestatus.st_mode;
64 finfo->nlink_ = filestatus.st_nlink;
65 finfo->size_ = filestatus.st_size;
68 return result;
71 int
72 ACE_FILE::get_info (ACE_FILE_Info &finfo)
74 ACE_TRACE ("ACE_FILE::get_info");
76 return this->get_info (&finfo);
79 int
80 ACE_FILE::truncate (ACE_OFF_T length)
82 ACE_TRACE ("ACE_FILE::truncate");
83 return ACE_OS::ftruncate (this->get_handle (), length);
86 ACE_OFF_T
87 ACE_FILE::seek (ACE_OFF_T offset, int startpos)
89 return ACE_OS::lseek (this->get_handle (), offset, startpos);
92 ACE_OFF_T
93 ACE_FILE::tell ()
95 ACE_TRACE ("ACE_FILE::tell");
96 return ACE_OS::lseek (this->get_handle (), 0, SEEK_CUR);
99 // Return the local endpoint address.
102 ACE_FILE::get_local_addr (ACE_Addr &addr) const
104 ACE_TRACE ("ACE_FILE::get_local_addr");
106 // Perform the downcast since <addr> had better be an
107 // <ACE_FILE_Addr>.
108 ACE_FILE_Addr *file_addr =
109 dynamic_cast<ACE_FILE_Addr *> (&addr);
111 if (file_addr == 0)
112 return -1;
113 else
115 *file_addr = this->addr_;
116 return 0;
120 // Return the same result as <get_local_addr>.
123 ACE_FILE::get_remote_addr (ACE_Addr &addr) const
125 ACE_TRACE ("ACE_FILE::get_remote_addr");
127 return this->get_local_addr (addr);
131 ACE_FILE::remove ()
133 ACE_TRACE ("ACE_FILE::remove");
135 this->close ();
136 return ACE_OS::unlink (this->addr_.get_path_name ());
140 ACE_FILE::unlink ()
142 ACE_TRACE ("ACE_FILE::unlink");
144 return ACE_OS::unlink (this->addr_.get_path_name ());
147 ACE_END_VERSIONED_NAMESPACE_DECL