home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / lib / OkFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.2 KB  |  74 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. ///////////////////////////////////////////////////////////////
  18. // OkFile.h --
  19. ///////////////////////////////////////////////////////////////
  20. #ifndef OKFILE_H
  21. #define OKFILE_H
  22.  
  23. #include <Xm/Xm.h>
  24. #include <stdio.h>
  25. #include <unistd.h>
  26. #include <iostream.h>
  27. #include <fstream.h>
  28.  
  29.  
  30. class OkFileItem;
  31.  
  32. class OkFile {
  33.  
  34.  private:
  35.   fstream    _file;
  36.  
  37.  public:
  38.   OkFile();
  39.   OkFile( const char* fileName=NULL, int mode=ios::in );
  40.   virtual ~OkFile();
  41.  
  42.   fstream& file()     { return _file; }
  43.  
  44.   void open( const char* fileName, int mode );
  45.   void close()        { _file.close(); }
  46.  
  47.   void read( OkFileItem* item );
  48.   void write( OkFileItem* item );
  49.  
  50.   // General purpose file manipulation functions:
  51.  
  52.   static Boolean Exists( const char* fileName ) 
  53.             { return ( ! access( fileName, F_OK ) ); }
  54.   static Boolean Readable( const char* fileName )
  55.             { return ( ! access( fileName, R_OK ) ); }
  56.   static Boolean Writable( const char* fileName )
  57.             { return ( ! access( fileName, W_OK ) ); }
  58.   static Boolean Executable( const char* fileName )
  59.             { return ( ! access( fileName, X_OK ) ); }
  60.  
  61.   static int Rename( const char* oldName, const char* newName )
  62.             { return rename( oldName, newName ); }
  63.   static int Unlink( const char* fileName )
  64.             { return unlink( fileName ); }
  65.  
  66.   // Caller is responsible to free the returned string.
  67.   static char* PathBaseName( const char* path );
  68.   static char* PathDirName( const char* path );
  69.   static char* PathExpandTilde( const char* path );
  70.  
  71. };
  72.  
  73. #endif
  74.