ObjFW
OFFile.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
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 #include <sys/stat.h>
26 
27 #import "OFSeekableStream.h"
28 
29 OF_ASSUME_NONNULL_BEGIN
30 
31 @class OFArray OF_GENERIC(ObjectType);
32 @class OFDate;
33 
34 #if defined(_WIN32)
35 typedef struct __stat64 of_stat_t;
36 #elif defined(OF_HAVE_OFF64_T)
37 typedef struct stat64 of_stat_t;
38 #else
39 typedef struct stat of_stat_t;
40 #endif
41 
48 {
49  int _fd;
50  bool _atEndOfStream;
51 }
52 
75 + (instancetype)fileWithPath: (OFString*)path
76  mode: (OFString*)mode;
77 
85 + (instancetype)fileWithFileDescriptor: (int)fd;
86 
92 + (OFString*)currentDirectoryPath;
93 
100 + (bool)fileExistsAtPath: (OFString*)path;
101 
108 + (bool)directoryExistsAtPath: (OFString*)path;
109 
110 #ifdef OF_HAVE_SYMLINK
111 
117 + (bool)symbolicLinkExistsAtPath: (OFString*)path;
118 #endif
119 
125 + (void)createDirectoryAtPath: (OFString*)path;
126 
133 + (void)createDirectoryAtPath: (OFString*)path
134  createParents: (bool)createParents;
135 
144 + (OFArray OF_GENERIC(OFString*)*)contentsOfDirectoryAtPath: (OFString*)path;
145 
151 + (void)changeCurrentDirectoryPath: (OFString*)path;
152 
160 + (of_offset_t)sizeOfFileAtPath: (OFString*)path;
161 
169 + (OFDate*)accessTimeOfItemAtPath: (OFString*)path;
170 
179 + (OFDate*)modificationTimeOfItemAtPath: (OFString*)path;
180 
189 + (OFDate*)statusChangeTimeOfItemAtPath: (OFString*)path;
190 
191 #ifdef OF_HAVE_CHMOD
192 
200 + (void)changePermissionsOfItemAtPath: (OFString*)path
201  permissions: (mode_t)permissions;
202 #endif
203 
204 #ifdef OF_HAVE_CHOWN
205 
214 + (void)changeOwnerOfItemAtPath: (OFString*)path
215  owner: (OFString*)owner
216  group: (OFString*)group;
217 #endif
218 
232 + (void)copyItemAtPath: (OFString*)source
233  toPath: (OFString*)destination;
234 
248 + (void)moveItemAtPath: (OFString*)source
249  toPath: (OFString*)destination;
250 
258 + (void)removeItemAtPath: (OFString*)path;
259 
260 #ifdef OF_HAVE_LINK
261 
272 + (void)linkItemAtPath: (OFString*)source
273  toPath: (OFString*)destination;
274 #endif
275 
276 #ifdef OF_HAVE_SYMLINK
277 
290 + (void)createSymbolicLinkAtPath: (OFString*)destination
291  withDestinationPath: (OFString*)source;
292 
300 + (OFString*)destinationOfSymbolicLinkAtPath: (OFString*)path;
301 #endif
302 
325 - initWithPath: (OFString*)path
326  mode: (OFString*)mode;
327 
334 - initWithFileDescriptor: (int)fd;
335 @end
336 
337 #ifdef __cplusplus
338 extern "C" {
339 #endif
340 extern int of_stat(OFString *path, of_stat_t *buffer);
341 extern int of_lstat(OFString *path, of_stat_t *buffer);
342 #ifdef __cplusplus
343 }
344 #endif
345 
346 OF_ASSUME_NONNULL_END
A class which provides functions to read, write and manipulate files.
Definition: OFFile.h:47
A class for handling strings.
Definition: OFString.h:91
A stream that supports seeking.
Definition: OFSeekableStream.h:51
A class for storing, accessing and comparing dates.
Definition: OFDate.h:30
An abstract class for storing objects in an array.
Definition: OFArray.h:95