ObjFW
Loading...
Searching...
No Matches
OFFile.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFSeekableStream.h"
21#import "OFKernelEventObserver.h"
22
23#ifndef OF_AMIGAOS
24# define OF_FILE_HANDLE_IS_FD
25typedef int OFFileHandle;
26static const OFFileHandle OFInvalidFileHandle = -1;
27#else
28typedef struct _OFFileHandle *OFFileHandle;
29static const OFFileHandle OFInvalidFileHandle = NULL;
30#endif
31
32OF_ASSUME_NONNULL_BEGIN
33
39OF_SUBCLASSING_RESTRICTED
41#ifdef OF_FILE_HANDLE_IS_FD
43#endif
44{
45 OFFileHandle _handle;
46 bool _initialized, _atEndOfStream;
47}
48
69+ (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode;
70
79+ (instancetype)fileWithHandle: (OFFileHandle)handle;
80
104- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode;
105
114- (instancetype)initWithHandle: (OFFileHandle)handle OF_DESIGNATED_INITIALIZER;
115
116- (instancetype)init OF_UNAVAILABLE;
117@end
118
119OF_ASSUME_NONNULL_END
A class which provides methods to read and write files.
Definition OFFile.h:41
A stream that supports seeking.
Definition OFSeekableStream.h:75
A class for handling strings.
Definition OFString.h:139
This protocol is implemented by classes which can be observed for readiness for reading by OFKernelEv...
Definition OFKernelEventObserver.h:88
This protocol is implemented by classes which can be observed for readiness for writing by OFKernelEv...
Definition OFKernelEventObserver.h:103