Back to index

lightning-sunbird  0.9+nobinonly
GUSIMacFile.h
Go to the documentation of this file.
00001 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
00002 // % Project  :      GUSI                        -      Grand Unified Socket Interface                    
00003 // % File            :      GUSIMacFile.nw              -      Disk files                                  
00004 // % Author   :      Matthias Neeracher                                           
00005 // % Language :      C++                                                        
00006 // %                                                                       
00007 // % $Log: GUSIMacFile.h,v $
00008 // % Revision 1.1  2001/03/11 22:35:45  sgehani%netscape.com
00009 // % First Checked In.
00010 // %                                              
00011 // % Revision 1.24  2001/01/17 08:58:06  neeri                             
00012 // % Releasing 2.1.4                                                       
00013 // %                                                                       
00014 // % Revision 1.23  2000/12/23 06:11:36  neeri                             
00015 // % Move diagnostics to A5 safe time                                      
00016 // %                                                                       
00017 // % Revision 1.22  2000/10/16 04:02:00  neeri                             
00018 // % Save A5 in completion routines                                        
00019 // %                                                                       
00020 // % Revision 1.21  2000/05/23 07:07:05  neeri                             
00021 // % Improve formatting, fix lseek for readonly files                      
00022 // %                                                                       
00023 // % Revision 1.20  2000/03/15 07:17:11  neeri                             
00024 // % Fix rename for existing targets                                       
00025 // %                                                                       
00026 // % Revision 1.19  2000/03/06 08:12:27  neeri                             
00027 // % New Yield system; fix readdir at end of directory                     
00028 // %                                                                       
00029 // % Revision 1.18  1999/11/15 07:24:32  neeri                             
00030 // % Return error for stat() of nonexistent files.                         
00031 // %                                                                       
00032 // % Revision 1.17  1999/09/09 07:19:19  neeri                             
00033 // % Fix read-ahead switch-off                                             
00034 // %                                                                       
00035 // % Revision 1.16  1999/08/26 05:45:05  neeri                             
00036 // % Fixes for literate edition of source code                             
00037 // %                                                                       
00038 // % Revision 1.15  1999/08/05 05:55:35  neeri                             
00039 // % Updated for CW Pro 5                                                  
00040 // %                                                                       
00041 // % Revision 1.14  1999/08/02 07:02:45  neeri                             
00042 // % Support for asynchronous errors and other socket options              
00043 // %                                                                       
00044 // % Revision 1.13  1999/07/19 06:21:03  neeri                             
00045 // % Add mkdir/rmdir, fix various file manager related bugs                
00046 // %                                                                       
00047 // % Revision 1.12  1999/07/07 04:17:41  neeri                             
00048 // % Final tweaks for 2.0b3                                                
00049 // %                                                                       
00050 // % Revision 1.11  1999/06/28 06:07:15  neeri                             
00051 // % Support I/O alignment, more effective writeback strategy              
00052 // %                                                                       
00053 // % Revision 1.10  1999/05/30 02:18:05  neeri                             
00054 // % Cleaner definition of GUSICatInfo                                     
00055 // %                                                                       
00056 // % Revision 1.9  1999/04/29 05:33:19  neeri                              
00057 // % Fix fcntl prototype                                                   
00058 // %                                                                       
00059 // % Revision 1.8  1999/04/10 04:54:39  neeri                              
00060 // % stat() was broken for directories                                     
00061 // %                                                                       
00062 // % Revision 1.7  1999/03/29 09:51:28  neeri                              
00063 // % New configuration system with support for hardcoded configurations.   
00064 // %                                                                       
00065 // % Revision 1.6  1999/03/17 09:05:09  neeri                              
00066 // % Added GUSITimer, expanded docs                                        
00067 // %                                                                       
00068 // % Revision 1.5  1998/11/22 23:06:57  neeri                              
00069 // % Releasing 2.0a4 in a hurry                                            
00070 // %                                                                       
00071 // % Revision 1.4  1998/10/11 16:45:19  neeri                              
00072 // % Ready to release 2.0a2                                                
00073 // %                                                                       
00074 // % Revision 1.3  1998/08/01 21:28:58  neeri                              
00075 // % Add directory operations                                              
00076 // %                                                                       
00077 // % Revision 1.2  1998/02/11 12:57:14  neeri                              
00078 // % PowerPC Build                                                         
00079 // %                                                                       
00080 // % Revision 1.1  1998/01/25 21:02:48  neeri                              
00081 // % Engine implemented, except for signals & scheduling                   
00082 // %                                                                       
00083 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
00084 //                                                                         
00085 // \chapter{Disk files}                                                    
00086 //                                                                         
00087 // A [[GUSIMacFileSocket]] implements the operations on mac files. All instances
00088 // of [[GUSIMacFileSocket]] are created by the [[GUSIMacFileDevice]] singleton, so
00089 // there is no point in exporting the class itself.                        
00090 //                                                                         
00091 // A [[GUSIMacDirectory]] implements directory handles on mac directories. 
00092 //                                                                         
00093 // <GUSIMacFile.h>=                                                        
00094 #ifndef _GUSIMacFile_
00095 #define _GUSIMacFile_
00096 
00097 #ifdef GUSI_INTERNAL
00098 
00099 #include "GUSIDevice.h"
00100 
00101 // \section{Definition of [[GUSIMacFileDevice]]}                           
00102 //                                                                         
00103 // [[GUSIMacFileDevice]] is a singleton subclass of [[GUSIDevice]].        
00104 //                                                                         
00105 // <Definition of class [[GUSIMacFileDevice]]>=                            
00106 class GUSIMacFileDevice : public GUSIDevice {
00107 public:
00108        static GUSIMacFileDevice *  Instance();
00109        virtual bool  Want(GUSIFileToken & file);
00110        
00111        // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00112  virtual GUSISocket * open(GUSIFileToken & file, int flags);
00113  // The normal case of [[remove]] is straightforward, but we also want to support
00114  // the removing of open files, which is frequently used in POSIX code, as much
00115  // as possible.                                                            
00116  //                                                                         
00117  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00118  virtual int remove(GUSIFileToken & file);
00119  // [[rename]] can be a surprisingly difficult operation.                   
00120  //                                                                         
00121  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00122  virtual int rename(GUSIFileToken & file, const char * newname);
00123  // [[stat]] is a rather intimidating function which needs to pull together 
00124  // information from various sources.                                       
00125  //                                                                         
00126  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00127  virtual int stat(GUSIFileToken & file, struct stat * buf);
00128  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00129  virtual int chmod(GUSIFileToken & file, mode_t mode);
00130  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00131  virtual int utime(GUSIFileToken & file, const utimbuf * times);
00132  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00133  virtual int access(GUSIFileToken & file, int mode);
00134  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00135  virtual int mkdir(GUSIFileToken & file);
00136  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00137  virtual int rmdir(GUSIFileToken & file);
00138  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00139  virtual GUSIDirectory * opendir(GUSIFileToken & file);
00140  // [[symlink]] has to reproduce the Finder's alias creation process, which is
00141  // quite complex.                                                          
00142  //                                                                         
00143  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00144  virtual int symlink(GUSIFileToken & to, const char * newlink);
00145  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00146  virtual int readlink(GUSIFileToken & link, char * buf, int bufsize);
00147  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00148  virtual int fgetfileinfo(GUSIFileToken & file, OSType * creator, OSType * type);
00149  virtual int fsetfileinfo(GUSIFileToken & file, OSType creator, OSType type);
00150  // [[faccess]] is a somewhat curious case in that [[GUSIMacFileDevice]]    
00151  // accepts responsibility for handling it, but then does not, in fact, handle
00152  // it.                                                                     
00153  //                                                                         
00154  // <Overridden member functions for [[GUSIMacFileDevice]]>=                
00155  virtual int faccess(GUSIFileToken & file, unsigned * cmd, void * arg);
00156        
00157        GUSISocket *  open(short fileRef, int flags);
00158        
00159        int                  MarkTemporary(const FSSpec & file);
00160        void                 CleanupTemporaries(bool giveup);
00161        
00162        ~GUSIMacFileDevice();
00163 protected:
00164        GUSIMacFileDevice()  : fTemporaries(0)           {}
00165 
00166        // [[MarkTemporary]] moves the file to the temporary folder and puts it on a list 
00167  // of death candidates.                                                    
00168  //                                                                         
00169  // <Privatissima of [[GUSIMacFileDevice]]>=                                
00170  struct TempQueue {
00171        TempQueue *   fNext;
00172        FSSpec        fSpec;
00173  } * fTemporaries;
00174 };
00175 
00176 #endif /* GUSI_INTERNAL */
00177 
00178 #endif /* _GUSIMacFile_ */