~ubuntu-branches/ubuntu/edgy/sope/edgy

« back to all changes in this revision

Viewing changes to libFoundation/Foundation/NSPosixFileDescriptor.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Ley
  • Date: 2005-08-19 16:53:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050819165331-hs683wz1osm708pw
Tags: upstream-4.4rc.2
ImportĀ upstreamĀ versionĀ 4.4rc.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
   NSPosixFileDescriptor.h
 
3
 
 
4
   Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
 
5
   All rights reserved.
 
6
 
 
7
   Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
 
8
 
 
9
   This file is part of libFoundation.
 
10
 
 
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
 
15
   documentation.
 
16
 
 
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.
 
23
*/
 
24
 
 
25
#ifndef __NSPosixFileDescriptor_h__
 
26
#define __NSPosixFileDescriptor_h__
 
27
 
 
28
#include <sys/types.h>
 
29
#include <sys/stat.h>
 
30
#include <fcntl.h>
 
31
 
 
32
#include <Foundation/NSObject.h>
 
33
#include <Foundation/NSRange.h>
 
34
 
 
35
@class NSData;
 
36
@class NSString;
 
37
 
 
38
typedef enum {
 
39
    NSPosixNoActivity = 0,
 
40
    NSPosixReadableActivity = 1,
 
41
    NSPosixWritableActivity = 2,
 
42
    NSPosixExceptionalActivity = 4
 
43
} NSPosixFileActivities;
 
44
 
 
45
@interface NSPosixFileDescriptor : NSObject
 
46
{
 
47
    int      fd;
 
48
    id       delegate;
 
49
    unsigned fileActivity;
 
50
    BOOL     owned;
 
51
}
 
52
 
 
53
// Getting a standard NSPosixFileDescriptor
 
54
 
 
55
+ (id)descriptorWithStandardInput;
 
56
+ (id)descriptorWithStandardOutput;
 
57
+ (id)descriptorWithStandardError;
 
58
 
 
59
// Initialize
 
60
 
 
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;
 
65
 
 
66
// Get FD
 
67
 
 
68
- (int)fileDescriptor;
 
69
 
 
70
// Read
 
71
 
 
72
- (NSData *)readEntireFile;
 
73
- (NSData *)readFileRange:(NSRange)aRange;
 
74
- (NSData *)readFileLength:(long)length;
 
75
- (NSData *)readRestOfFile;
 
76
- (void)readBytes:(void*)bytes range:(NSRange)range;
 
77
 
 
78
// Write
 
79
 
 
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;
 
84
 
 
85
// Seek & Truncate
 
86
 
 
87
- (int unsigned)fileLength;
 
88
- (int unsigned)filePosition;
 
89
- (void)seekToEnd;
 
90
- (void)seekToPosition:(long)aPosition;
 
91
- (void)truncateAtPosition:(long)aPosition;
 
92
 
 
93
// Mapping files to memory
 
94
 
 
95
- (NSData *)mapFileRange:(NSRange)range;
 
96
- (void)synchronizeFile;
 
97
 
 
98
// Monitoring file descriptors
 
99
 
 
100
- (void)monitorFileActivity:(NSPosixFileActivities)activity;
 
101
- (void)monitorActivity:(NSPosixFileActivities)activity delegate:(id)delegate;
 
102
- (void)ceaseMonitoringFileActivity;
 
103
- (NSPosixFileActivities)fileActivity;
 
104
 
 
105
// File descriptor delegate
 
106
 
 
107
- (id)delegate;
 
108
- (void)setDelegate:(id)delegate;
 
109
 
 
110
@end /* NSPosixFileDescriptor */
 
111
 
 
112
 
 
113
@interface NSObject (NSPosixFileDescriptorDelegateMethod)
 
114
 
 
115
- (void)activity:(NSPosixFileActivities)activity
 
116
  posixFileDescriptor:(NSPosixFileDescriptor *)fileDescriptor;
 
117
 
 
118
@end
 
119
 
 
120
LF_EXPORT NSString *NSPosixFileOperationException;
 
121
 
 
122
#endif /* __NSPosixFileDescriptor_h__ */
 
123
 
 
124
/*
 
125
  Local Variables:
 
126
  c-basic-offset: 4
 
127
  tab-width: 8
 
128
  End:
 
129
*/