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

FILE.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    FILE.h
00006  *
00007  *  $Id: FILE.h,v 1.1.1.4 2003/02/21 18:36:32 chad 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 /**
00039  * @class ACE_FILE_Info
00040  *
00041  * @brief Abstracts basic OS FILE information.
00042  */
00043 class ACE_Export ACE_FILE_Info
00044 {
00045 public:
00046   /// Mode of file
00047   mode_t mode_;
00048 
00049   /// No of links
00050   nlink_t nlink_;
00051 
00052   /// Size of file
00053   off_t size_;
00054 };
00055 
00056 /**
00057  * @class ACE_FILE
00058  *
00059  * @brief Defines the core methods of the ACE_FILE abstraction.
00060  */
00061 class ACE_Export ACE_FILE : public ACE_IO_SAP
00062 {
00063 public:
00064   /// Close the ACE_FILE handle without removing the ACE_FILE from
00065   /// the file system.
00066   int close (void);
00067 
00068   /// Close and remove the ACE_FILE from the file system.
00069   int remove (void);
00070 
00071   /// Remove the ACE_FILE from the file system without closing the
00072   /// ACE_FILE handle.
00073   int unlink (void);
00074 
00075   /// Get information on this ACE_FILE.
00076   int get_info (ACE_FILE_Info *finfo);
00077 
00078   /// Get information on this <ACE_FILE>.
00079   int get_info (ACE_FILE_Info &finfo);
00080 
00081   /// Set filesize to length byte.
00082   int truncate (off_t length);
00083 
00084   /**
00085    * Sets the file pointer as follows:
00086    *    o If <whence> is <SEEK_SET>, the pointer is set to <offset>
00087    *      bytes.
00088    *
00089    *    o  If <whence> is <SEEK_CUR>, the pointer is set to its
00090    *       current location plus <offset>.
00091    *
00092    *    o  If <whence> is <SEEK_END>, the pointer is set to the size
00093    *       of the file plus offset.
00094    * Same as <seek>, but <position> is deprecated.
00095    */
00096   off_t seek (off_t offset,
00097               int whence = SEEK_CUR);
00098   off_t position (long offset, int startpos);
00099 
00100   /// Return an offset for the file handle.
00101   off_t tell (void);
00102 
00103   /**
00104    * @deprecated
00105    * Same as tell(), but position() is deprecated.
00106    */
00107   off_t position (void);
00108 
00109   /**
00110    * Disable signal @a signum
00111    * This is here to prevent Win32 from
00112    * disabling SPIPE using socket calls
00113    */
00114   int disable (int signum) const ;
00115 
00116   /// Return the local endpoint address in the referenced ACE_Addr.
00117   /// Returns 0 if successful, else -1.
00118   int get_local_addr (ACE_Addr &) const;
00119 
00120   /// Return the same thing as get_local_addr().
00121   int get_remote_addr (ACE_Addr &) const;
00122 
00123   /// Dump the state of an object.
00124   void dump (void) const;
00125 
00126   /// Declare the dynamic allocation hooks.
00127   ACE_ALLOC_HOOK_DECLARE;
00128 
00129 protected:
00130   /// Ensure that this class is only created by the
00131   /// ACE_FILE_Connector.
00132   ACE_FILE (void);
00133 
00134   /// File we are "connected" with...
00135   ACE_FILE_Addr addr_;
00136 };
00137 
00138 #if !defined (ACE_LACKS_INLINE_FUNCTIONS)
00139 #include "ace/FILE.i"
00140 #endif /* ACE_LACKS_INLINE_FUNCTIONS */
00141 
00142 #include "ace/post.h"
00143 #endif /* ACE_FILE_H */

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