home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / emulators / v9t9 / linux / sources / V9t9 / source / OSLib / OSLibGeneric.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-19  |  3.2 KB  |  110 lines

  1. #ifndef __INSIDE_OSLIB_H__
  2. #error Only include this file in OSLib.h
  3. #endif
  4.  
  5. /*************************************/
  6. /*    Generic routines implementation     */
  7. /*************************************/
  8.  
  9. /*    perform wildcard matching on a path; 
  10.     if path is non-NULL, start a search
  11.     else continue searching; 
  12.     return NULL if no match found;
  13.     only matches filenames           */
  14. OSSpec *
  15. OS_MatchPath(const char *path);
  16.  
  17. /*    Return pointer to filename part of path */
  18. const char *
  19. OS_GetFileNamePtr(const char *path);
  20.  
  21. /*    Compress path + name into buf, which size bytes long,
  22.     by inserting '...' in the middle */
  23. char *
  24. OS_CompactPaths(char *buf, const char *path, const char *name, int size);
  25.  
  26. /*    make OSSpec from a path and filename */
  27. OSError
  28. OS_MakeSpec2(const char *path, const char *filename, OSSpec *spec);
  29.  
  30. /*    make OSSpec given a path and possibly relative path (which may be NULL);
  31.     if filename is relative and noRelative is set, or if filename is full path, 
  32.     then ignore 'path'. */
  33. enum { mswp_noRelative = true };
  34. OSError
  35. OS_MakeSpecWithPath(const OSPathSpec *path, const char *filename, bool noRelative, OSSpec *spec);
  36.  
  37. /*    change extension of a name; do not exceed OS_NAMESIZE */
  38. OSError
  39. OS_NameSpecChangeExtension(OSNameSpec *spec, char *ext, bool append);
  40.  
  41. /*    set the extension of a name; if ext begins with '.', append the extension, else replace it */
  42. OSError
  43. OS_NameSpecSetExtension(OSNameSpec *spec, char *ext);
  44.  
  45. /*    make a relative filepath from the spec from cwd;
  46.     if cwd is NULL, use actual cwd */
  47. char *
  48. OS_SpecToStringRelative(const OSSpec *spec, const OSPathSpec *cwd, char *path, int size);
  49.  
  50. #define OS_SpecToStringRelative1(spec) \
  51.     OS_SpecToStringRelative(spec, NULL, STSbuf, OS_PATHSIZE)
  52. #define OS_SpecToStringRelative2(spec,buf) \
  53.     OS_SpecToStringRelative(spec, NULL, buf, OS_PATHSIZE)
  54.  
  55. /*    Search for a file in a list; if not found, returns error and
  56.     creates OSSpec in first directory in plist. */
  57. OSError    
  58. OS_FindFileInPath(const char *filename, const char *plist, OSSpec *spec);
  59.  
  60. /*    Search for a place to create file in a list; 
  61.     if not possible, returns error */
  62. OSError    
  63. OS_CreateFileInPath(const char *filename, const char *plist, OSSpec *spec, OSFileType *type);
  64.  
  65. /*    Search for an executable using the OS standards;
  66.     filename should have appropriate extension if necessary;
  67.     if relative path or not found, make spec in CWD  */
  68. OSError    
  69. OS_FindProgram(const char *filename, OSSpec *spec);
  70.  
  71. /*    Copy a handle. */
  72. OSError
  73. OS_CopyHandle(OSHandle *hand, OSHandle *copy);
  74.  
  75. /*    Append data to a handle. */
  76. OSError
  77. OS_AppendHandle(OSHandle *hand, void *data, OSSize len);
  78.  
  79. typedef struct
  80. {
  81.     OSSpec        spec;
  82.     OSHandle    hand;
  83.     bool        loaded,changed,writeable;
  84. }    OSFileHandle;
  85.  
  86. /*    Create a new file handle from a given spec;
  87.     if src is non-NULL, copy this handle (don't link) */
  88. OSError    
  89. OS_NewFileHandle(OSSpec *spec, OSHandle *src, 
  90.                 bool writeable, OSFileHandle *hand);
  91.  
  92. /*    Lock a file handle into memory  */
  93. OSError    
  94. OS_LockFileHandle(OSFileHandle *hand, void **ptr, OSSize *size);
  95.  
  96. /*    Unlock file handle */
  97. OSError    
  98. OS_UnlockFileHandle(OSFileHandle *hand, void *ptr);
  99.  
  100. /*    Dispose file handle; 
  101.     this guarantees that changes are flushed */
  102. OSError    
  103. OS_FreeFileHandle(OSFileHandle *hand);
  104.  
  105. /*    Get spec from the file handle */
  106. void    
  107. OS_GetFileHandleSpec(OSFileHandle *hand, OSSpec *spec);
  108.  
  109.  
  110.