FILE.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    FILE.h
00006  *
00007  *  FILE.h,v 4.26 2006/06/09 07:51:08 jwillemsen Exp
00008  *
00009  *  @author Gerhard Lenzer
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_FILE_H
00014 #define ACE_FILE_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/IO_SAP.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ace/FILE_Addr.h"
00024 
00025 // The following is necessary since many C++ compilers don't support
00026 // typedef'd types inside of classes used as formal template
00027 // arguments... ;-(.  Luckily, using the C++ preprocessor I can hide
00028 // most of this nastiness!
00029 
00030 #if defined (ACE_HAS_TEMPLATE_TYPEDEFS)
00031 #define ACE_FILE_CONNECTOR ACE_FILE_Connector
00032 #define ACE_FILE_STREAM ACE_FILE_IO
00033 #else /* TEMPLATES are broken (must be a cfront-based compiler...) */
00034 #define ACE_FILE_CONNECTOR ACE_FILE_Connector, ACE_FILE_Addr
00035 #define ACE_FILE_STREAM ACE_FILE_IO, ACE_FILE_Addr
00036 #endif /* ACE_TEMPLATE_TYPEDEFS */
00037 
00038 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00039 
00040 /**
00041  * @class ACE_FILE_Info
00042  *
00043  * @brief Abstracts basic OS FILE information.
00044  */
00045 class ACE_Export ACE_FILE_Info
00046 {
00047 public:
00048   /// Mode of file
00049   mode_t mode_;
00050 
00051   /// No of links
00052   nlink_t nlink_;
00053 
00054   /// Size of file
00055   ACE_LOFF_T size_;
00056 };
00057 
00058 /**
00059  * @class ACE_FILE
00060  *
00061  * @brief Defines the core methods of the ACE_FILE abstraction.
00062  */
00063 class ACE_Export ACE_FILE : public ACE_IO_SAP
00064 {
00065 public:
00066   /// Close the ACE_FILE handle without removing the ACE_FILE from
00067   /// the file system.
00068   int close (void);
00069 
00070   /// Close and remove the ACE_FILE from the file system.
00071   int remove (void);
00072 
00073   /// Remove the ACE_FILE from the file system without closing the
00074   /// ACE_FILE handle.
00075   int unlink (void);
00076 
00077   /// Get information on this ACE_FILE.
00078   int get_info (ACE_FILE_Info *finfo);
00079 
00080   /// Get information on this <ACE_FILE>.
00081   int get_info (ACE_FILE_Info &finfo);
00082 
00083   /// Set filesize to length byte.
00084   int truncate (off_t length);
00085 
00086   /**
00087    * Sets the file pointer as follows:
00088    *    o If <whence> is <SEEK_SET>, the pointer is set to <offset>
00089    *      bytes.
00090    *
00091    *    o  If <whence> is <SEEK_CUR>, the pointer is set to its
00092    *       current location plus <offset>.
00093    *
00094    *    o  If <whence> is <SEEK_END>, the pointer is set to the size
00095    *       of the file plus offset.
00096    */
00097   off_t seek (off_t offset,
00098               int whence = SEEK_CUR);
00099 
00100   /// Return an offset for the file handle.
00101   off_t tell (void);
00102 
00103   /**
00104    * Disable signal @a signum
00105    * This is here to prevent Win32 from
00106    * disabling SPIPE using socket calls
00107    */
00108   int disable (int signum) const ;
00109 
00110   /// Return the local endpoint address in the referenced ACE_Addr.
00111   /// Returns 0 if successful, else -1.
00112   int get_local_addr (ACE_Addr &) const;
00113 
00114   /// Return the same thing as get_local_addr().
00115   int get_remote_addr (ACE_Addr &) const;
00116 
00117   /// Dump the state of an object.
00118   void dump (void) const;
00119 
00120   /// Declare the dynamic allocation hooks.
00121   ACE_ALLOC_HOOK_DECLARE;
00122 
00123 protected:
00124   /// Ensure that this class is only created by the
00125   /// ACE_FILE_Connector.
00126   ACE_FILE (void);
00127 
00128   /// File we are "connected" with...
00129   ACE_FILE_Addr addr_;
00130 };
00131 
00132 ACE_END_VERSIONED_NAMESPACE_DECL
00133 
00134 #if defined (__ACE_INLINE__)
00135 #include "ace/FILE.inl"
00136 #endif /* __ACE_INLINE__ */
00137 
00138 #include /**/ "ace/post.h"
00139 #endif /* ACE_FILE_H */

Generated on Thu Nov 9 09:41:50 2006 for ACE by doxygen 1.3.6