ObjFW
OFFileManager.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
3  * Jonathan Schleifer <js@heap.zone>
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 #import "OFObject.h"
18 #import "OFSeekableStream.h"
19 
20 OF_ASSUME_NONNULL_BEGIN
21 
22 #if defined(OF_HAVE_CHMOD) && !defined(OF_MORPHOS)
23 # define OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
24 #endif
25 #if defined(OF_HAVE_CHOWN) && !defined(OF_MORPHOS)
26 # define OF_FILE_MANAGER_SUPPORTS_OWNER
27 #endif
28 #if (defined(OF_HAVE_LINK) && !defined(OF_MORPHOS)) || defined(OF_WINDOWS)
29 # define OF_FILE_MANAGER_SUPPORTS_LINKS
30 #endif
31 #if (defined(OF_HAVE_SYMLINK) && !defined(OF_MORPHOS)) || defined(OF_WINDOWS)
32 # define OF_FILE_MANAGER_SUPPORTS_SYMLINKS
33 #endif
34 
35 @class OFArray OF_GENERIC(ObjectType);
36 @class OFDate;
37 
49 
56 
63 - (bool)fileExistsAtPath: (OFString *)path;
64 
71 - (bool)directoryExistsAtPath: (OFString *)path;
72 
73 #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
74 
80 - (bool)symbolicLinkExistsAtPath: (OFString *)path;
81 #endif
82 
88 - (void)createDirectoryAtPath: (OFString *)path;
89 
96 - (void)createDirectoryAtPath: (OFString *)path
97  createParents: (bool)createParents;
98 
107 - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path;
108 
114 - (void)changeCurrentDirectoryPath: (OFString *)path;
115 
123 - (of_offset_t)sizeOfFileAtPath: (OFString *)path;
124 
132 - (OFDate *)accessTimeOfItemAtPath: (OFString *)path;
133 
142 - (OFDate *)modificationTimeOfItemAtPath: (OFString *)path;
143 
152 - (OFDate *)statusChangeTimeOfItemAtPath: (OFString *)path;
153 
154 #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
155 
166 - (uint16_t)permissionsOfItemAtPath: (OFString *)path;
167 
180 - (void)changePermissionsOfItemAtPath: (OFString *)path
181  permissions: (uint16_t)permissions;
182 #endif
183 
184 #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
185 
192 - (void)getOwner: (OFString *__autoreleasing _Nonnull *_Nullable)owner
193  group: (OFString *__autoreleasing _Nonnull *_Nullable)group
194  ofItemAtPath: (OFString *)path;
195 
205 - (void)changeOwnerOfItemAtPath: (OFString *)path
206  owner: (OFString *)owner
207  group: (OFString *)group;
208 #endif
209 
223 - (void)copyItemAtPath: (OFString *)source
224  toPath: (OFString *)destination;
225 
239 - (void)moveItemAtPath: (OFString *)source
240  toPath: (OFString *)destination;
241 
249 - (void)removeItemAtPath: (OFString *)path;
250 
251 #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
252 
263 - (void)linkItemAtPath: (OFString *)source
264  toPath: (OFString *)destination;
265 #endif
266 
267 #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
268 
284 - (void)createSymbolicLinkAtPath: (OFString *)destination
285  withDestinationPath: (OFString *)source;
286 
296 - (OFString *)destinationOfSymbolicLinkAtPath: (OFString *)path;
297 #endif
298 @end
299 
300 OF_ASSUME_NONNULL_END
OFString * currentDirectoryPath()
Returns the path for the current working directory.
Definition: OFFileManager.m:247
A class for handling strings.
Definition: OFString.h:114
OFFileManager * defaultManager()
Returns the default file manager.
Definition: OFFileManager.m:242
The root class for all other classes inside ObjFW.
Definition: OFObject.h:379
A class for storing, accessing and comparing dates.
Definition: OFDate.h:30
An abstract class for storing objects in an array.
Definition: OFArray.h:89
A class which provides management for files, e.g. reading contents of directories, deleting files, renaming files, etc.
Definition: OFFileManager.h:44