2
NSPosixFileDescriptor.h
4
Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
7
Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
9
This file is part of libFoundation.
11
Permission to use, copy, modify, and distribute this software and its
12
documentation for any purpose and without fee is hereby granted, provided
13
that the above copyright notice appear in all copies and that both that
14
copyright notice and this permission notice appear in supporting
17
We disclaim all warranties with regard to this software, including all
18
implied warranties of merchantability and fitness, in no event shall
19
we be liable for any special, indirect or consequential damages or any
20
damages whatsoever resulting from loss of use, data or profits, whether in
21
an action of contract, negligence or other tortious action, arising out of
22
or in connection with the use or performance of this software.
25
#ifndef __NSPosixFileDescriptor_h__
26
#define __NSPosixFileDescriptor_h__
28
#include <sys/types.h>
32
#include <Foundation/NSObject.h>
33
#include <Foundation/NSRange.h>
39
NSPosixNoActivity = 0,
40
NSPosixReadableActivity = 1,
41
NSPosixWritableActivity = 2,
42
NSPosixExceptionalActivity = 4
43
} NSPosixFileActivities;
45
@interface NSPosixFileDescriptor : NSObject
49
unsigned fileActivity;
53
// Getting a standard NSPosixFileDescriptor
55
+ (id)descriptorWithStandardInput;
56
+ (id)descriptorWithStandardOutput;
57
+ (id)descriptorWithStandardError;
61
- (id)initWithFileDescriptor:(int)fileDescriptor;
62
- (id)initWithPath:(NSString*)aPath;
63
- (id)initWithPath:(NSString*)aPath flags:(int)flags;
64
- (id)initWithPath:(NSString*)aPath flags:(int)flags createMode:(int)mode;
68
- (int)fileDescriptor;
72
- (NSData *)readEntireFile;
73
- (NSData *)readFileRange:(NSRange)aRange;
74
- (NSData *)readFileLength:(long)length;
75
- (NSData *)readRestOfFile;
76
- (void)readBytes:(void*)bytes range:(NSRange)range;
80
- (void)writeData:(NSData*)aData;
81
- (void)writeData:(NSData*)aData range:(NSRange)aRange;
82
- (void)writeString:(NSString*)string;
83
- (void)writeString:(NSString*)string range:(NSRange)aRange;
87
- (int unsigned)fileLength;
88
- (int unsigned)filePosition;
90
- (void)seekToPosition:(long)aPosition;
91
- (void)truncateAtPosition:(long)aPosition;
93
// Mapping files to memory
95
- (NSData *)mapFileRange:(NSRange)range;
96
- (void)synchronizeFile;
98
// Monitoring file descriptors
100
- (void)monitorFileActivity:(NSPosixFileActivities)activity;
101
- (void)monitorActivity:(NSPosixFileActivities)activity delegate:(id)delegate;
102
- (void)ceaseMonitoringFileActivity;
103
- (NSPosixFileActivities)fileActivity;
105
// File descriptor delegate
108
- (void)setDelegate:(id)delegate;
110
@end /* NSPosixFileDescriptor */
113
@interface NSObject (NSPosixFileDescriptorDelegateMethod)
115
- (void)activity:(NSPosixFileActivities)activity
116
posixFileDescriptor:(NSPosixFileDescriptor *)fileDescriptor;
120
LF_EXPORT NSString *NSPosixFileOperationException;
122
#endif /* __NSPosixFileDescriptor_h__ */