home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / i / iv26_w_3.zip / EXAMPLES / ICLASS / DIRECTOR.H < prev    next >
C/C++ Source or Header  |  1980-01-03  |  3KB  |  74 lines

  1. /*
  2.  * Copyright (c) 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Directory - a class interface to Unix directory operations.
  25.  */
  26.  
  27. #ifndef direct_h
  28. #define direct_h
  29.  
  30. #include <InterViews/defs.h>
  31.  
  32. class Directory {       
  33. public:
  34.     Directory(const char* name);
  35.     ~Directory();
  36.  
  37.     boolean LoadDirectory(const char*);
  38.     const char* Normalize(const char*);
  39.     const char* ValidDirectories(const char*);
  40.  
  41.     int Index(const char*);
  42.     const char* File(int index);
  43.     int Count();
  44.  
  45.     boolean IsADirectory(const char*);
  46. private:
  47.     const char* Home(const char* = nil);
  48.     const char* ElimDot(const char*);
  49.     const char* ElimDotDot(const char*);
  50.     const char* InterpSlashSlash(const char*);
  51.     const char* InterpTilde(const char*);
  52.     const char* ExpandTilde(const char*, int);
  53.     const char* RealPath(const char*);
  54.  
  55.     boolean Reset(const char*);
  56.     void Clear();
  57.     void Insert(const char*, int index);
  58.     void Append(const char*);
  59.     void Remove(int index);
  60.     virtual int Position(const char*);
  61. private:
  62.     char** strbuf;
  63.     int strcount;
  64.     int strbufsize;
  65. };
  66.  
  67. inline int Directory::Count () { return strcount; }
  68. inline void Directory::Append (const char* s) { Insert(s, strcount); }
  69. inline const char* Directory::File (int index) { 
  70.     return (0 <= index && index < strcount) ? strbuf[index] : nil;
  71. }
  72.  
  73. #endif
  74.