1 /* Defines the member functions for the base class of the ACE_IO_SAP
2 ACE_FILE abstraction. */
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
)
22 ACE_FILE::dump () const
24 #if defined (ACE_HAS_DUMP)
25 ACE_TRACE ("ACE_FILE::dump");
27 #endif /* ACE_HAS_DUMP */
30 // This is the do-nothing constructor.
34 ACE_TRACE ("ACE_FILE::ACE_FILE");
42 ACE_TRACE ("ACE_FILE::close");
45 if (this->get_handle () != ACE_INVALID_HANDLE
)
47 result
= ACE_OS::close (this->get_handle ());
48 this->set_handle (ACE_INVALID_HANDLE
);
54 ACE_FILE::get_info (ACE_FILE_Info
*finfo
)
56 ACE_TRACE ("ACE_FILE::get_info");
59 int const result
= ACE_OS::fstat (this->get_handle (), &filestatus
);
63 finfo
->mode_
= filestatus
.st_mode
;
64 finfo
->nlink_
= filestatus
.st_nlink
;
65 finfo
->size_
= filestatus
.st_size
;
72 ACE_FILE::get_info (ACE_FILE_Info
&finfo
)
74 ACE_TRACE ("ACE_FILE::get_info");
76 return this->get_info (&finfo
);
80 ACE_FILE::truncate (ACE_OFF_T length
)
82 ACE_TRACE ("ACE_FILE::truncate");
83 return ACE_OS::ftruncate (this->get_handle (), length
);
87 ACE_FILE::seek (ACE_OFF_T offset
, int startpos
)
89 return ACE_OS::lseek (this->get_handle (), offset
, startpos
);
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
108 ACE_FILE_Addr
*file_addr
=
109 dynamic_cast<ACE_FILE_Addr
*> (&addr
);
115 *file_addr
= this->addr_
;
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
);
133 ACE_TRACE ("ACE_FILE::remove");
136 return ACE_OS::unlink (this->addr_
.get_path_name ());
142 ACE_TRACE ("ACE_FILE::unlink");
144 return ACE_OS::unlink (this->addr_
.get_path_name ());
147 ACE_END_VERSIONED_NAMESPACE_DECL