ObjFW
OFFile.h
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFSeekableStream.h"
17 #import "OFKernelEventObserver.h"
18 
19 #ifndef OF_AMIGAOS
20 # define OF_FILE_HANDLE_IS_FD
21 # define OF_INVALID_FILE_HANDLE (-1)
22 typedef int of_file_handle_t;
23 #else
24 # define OF_INVALID_FILE_HANDLE NULL
25 typedef struct of_file_handle *of_file_handle_t;
26 #endif
27 
28 OF_ASSUME_NONNULL_BEGIN
29 
30 @class OFURL;
31 
37 OF_SUBCLASSING_RESTRICTED
39 #ifdef OF_FILE_HANDLE_IS_FD
41 #endif
42 {
43  of_file_handle_t _handle;
44  bool _atEndOfStream;
45 }
46 
66 + (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode;
67 
86 + (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode;
87 
96 + (instancetype)fileWithHandle: (of_file_handle_t)handle;
97 
98 - (instancetype)init OF_UNAVAILABLE;
99 
122 - (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode;
123 
146 - (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode;
147 
156 - (instancetype)initWithHandle: (of_file_handle_t)handle
157  OF_DESIGNATED_INITIALIZER;
158 @end
159 
160 OF_ASSUME_NONNULL_END
A class which provides methods to read and write files.
Definition: OFFile.h:39
A stream that supports seeking.
Definition: OFSeekableStream.h:57
A class for handling strings.
Definition: OFString.h:132
A class for parsing URLs and accessing parts of it.
Definition: OFURL.h:34
This protocol is implemented by classes which can be observed for readiness for reading by OFKernelEv...
Definition: OFKernelEventObserver.h:85
This protocol is implemented by classes which can be observed for readiness for writing by OFKernelEv...
Definition: OFKernelEventObserver.h:100