ObjFW
 All Classes Functions Variables
OFFile.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #ifndef __STDC_LIMIT_MACROS
18 # define __STDC_LIMIT_MACROS
19 #endif
20 #ifndef __STDC_CONSTANT_MACROS
21 # define __STDC_CONSTANT_MACROS
22 #endif
23 
24 #include <sys/types.h>
25 
26 #import "OFSeekableStream.h"
27 
28 @class OFArray;
29 @class OFDate;
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 extern void of_log(OFConstantString*, ...);
35 #ifdef __cplusplus
36 }
37 #endif
38 
43 {
44  int fd;
45  BOOL closable;
46  BOOL atEndOfStream;
47 }
48 
56 + (instancetype)fileWithPath: (OFString*)path
57  mode: (OFString*)mode;
58 
66 + (instancetype)fileWithFileDescriptor: (int)fileDescriptor;
67 
73 + (OFString*)currentDirectoryPath;
74 
81 + (BOOL)fileExistsAtPath: (OFString*)path;
82 
89 + (BOOL)directoryExistsAtPath: (OFString*)path;
90 
96 + (void)createDirectoryAtPath: (OFString*)path;
97 
104 + (void)createDirectoryAtPath: (OFString*)path
105  createParents: (BOOL)createParents;
106 
113 + (OFArray*)filesInDirectoryAtPath: (OFString*)path;
114 
120 + (void)changeToDirectoryAtPath: (OFString*)path;
121 
127 + (off_t)sizeOfFileAtPath: (OFString*)path;
128 
134 + (OFDate*)modificationDateOfFileAtPath: (OFString*)path;
135 
136 #ifndef _PSP
137 
146 + (void)changeModeOfFileAtPath: (OFString*)path
147  mode: (mode_t)mode;
148 #endif
149 
150 #if !defined(_WIN32) && !defined(_PSP)
151 
161 + (void)changeOwnerOfFileAtPath: (OFString*)path
162  owner: (OFString*)owner
163  group: (OFString*)group;
164 #endif
165 
172 + (void)copyFileAtPath: (OFString*)source
173  toPath: (OFString*)destination;
174 
181 + (void)renameFileAtPath: (OFString*)source
182  toPath: (OFString*)destination;
183 
189 + (void)deleteFileAtPath: (OFString*)path;
190 
196 + (void)deleteDirectoryAtPath: (OFString*)path;
197 
198 #ifndef _WIN32
199 
207 + (void)linkFileAtPath: (OFString*)source
208  toPath: (OFString*)destination;
209 #endif
210 
211 #if !defined(_WIN32) && !defined(_PSP)
212 
220 + (void)symlinkFileAtPath: (OFString*)source
221  toPath: (OFString*)destination;
222 #endif
223 
231 - initWithPath: (OFString*)path
232  mode: (OFString*)mode;
233 
240 - initWithFileDescriptor: (int)fileDescriptor;
241 @end
242 
243 #ifdef __cplusplus
244 extern "C" {
245 #endif
246 extern OFStream *of_stdin;
247 extern OFStream *of_stdout;
248 extern OFStream *of_stderr;
249 #ifdef __cplusplus
250 }
251 #endif