home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextLibrary / Frameworks / NEXTIME.framework / Versions / A / Headers / NTFileIO.h < prev    next >
Encoding:
Text File  |  1995-08-30  |  1.7 KB  |  56 lines

  1. /*
  2.  *  NTFileIO.h
  3.  *     Copyright 1993, NeXT Computer, Inc.
  4.  *    
  5.  *    Protocol to be implemented by File IO objects which are used by
  6.  *    a media object.  The protocol specifies the API used by a media object
  7.  *    in reading samples from a file or appending samples to a file, and the
  8.  *    methods to be used in enabling or disabling write access.
  9.  *
  10.  *    19 April 1993 mpaque Created.
  11.  */
  12. #import <Foundation/NSObject.h>
  13. #import <Foundation/NSString.h>
  14.  
  15. typedef unsigned long NTFilePosition;
  16. typedef unsigned long NTFileSize;
  17.  
  18. @protocol NTFileIO <NSObject>
  19.  
  20. /*
  21.  * These methods all return nil on an error, or self on success.
  22.  * In the event of an error in readData, the contents of the NSData buffer are
  23.  * undefined.
  24.  */
  25. - initWithFile:(NSString *)name forWriting:(BOOL)writable;
  26. - initWithFile:(NSString *)name;
  27. - (void)dealloc;
  28. - (void)truncate:(NTFilePosition)pos;
  29. - (NTFilePosition)currentPosition;
  30. - (NTFilePosition)length;    /* Current file length */
  31. - (BOOL)setWriteEnable:(BOOL)writable;
  32. - (BOOL)isWriteEnabled;
  33. - (NSString *)filename;
  34.  
  35. - readData:(NSMutableData *)data fromPosition:(NTFilePosition)pos;
  36. - appendData:(NSData *)data atPosition:(NTFilePosition *)pos;
  37.  
  38. - (NTFileSize)readBytes:(void *)data maxLength:(NTFileSize)len fromPosition:(NTFilePosition)pos;
  39. - (NTFileSize)writeBytes:(void *)data length:(NTFileSize)len toPosition:(NTFilePosition)pos;
  40. - (NTFileSize)appendBytes:(void *)data length:(NTFileSize)len atPosition:(NTFilePosition *)pos;
  41. @end
  42.  
  43. /*
  44.  * File I/O implementation for large data transfers. This is a simple
  45.  * thread-safe wrapper around traditional Unix I/O operations.
  46.  * It should be portable to non-Unix systems with litle difficulty.
  47.  */
  48.  
  49. @interface NTFileIO: NSObject <NTFileIO>
  50. {
  51. @private
  52.     id <NTFileIO>    sharedFile;
  53.     BOOL        isWritable;
  54. }
  55. @end
  56.