ObjFW  Diff

Differences From Artifact [9ede7ee4ac]:

To Artifact [296a9224ed]:


32
33
34
35
36
37
38
39
40


41
42
43
44
45
46
47
48
49
50


51
52
53
54



55
56
57
58
59
60


61
62

63
64

65
66
67
68
69


70
71

72
73
74
75
76


77
78
79


80
81
82
83
84


85
86
87


88
89
90
91
92


93
94

95
96
97
98
99


100
101
102


103
104
105
106
107
108


109
110
111


112
113
114
115
116


117
118

119
120
121
122
123


124
125

126
127
128
129
130


131
132

133
134
135
136
137
138


139
140
141
142

143
144

145
146
147
148
149
150
151
152


153
154
155
156

157
158
159


160
161
162
163
164
165
166
167


168
169
170


171
172
173
174
175
176


177
178
179


180
181
182
183
184
185


186
187

188
189
190
191
192


193
194

195
196
197
198
199
200


201
202
203
204
205


206
207
208
209
210
211
212
213


214
215
216
217
218


219
220
221
222
223
224
225


226
227
228
229



230
231
232
233
234
235


236
237

238
239
240
241
242
243
244
32
33
34
35
36
37
38


39
40
41
42
43
44
45
46
47
48


49
50
51



52
53
54
55
56
57
58


59
60
61

62
63

64
65
66
67


68
69
70

71
72
73
74


75
76
77


78
79
80
81
82


83
84
85


86
87
88
89
90


91
92
93

94
95
96
97


98
99
100


101
102
103
104
105
106


107
108
109


110
111
112
113
114


115
116
117

118
119
120
121


122
123
124

125
126
127
128


129
130
131

132
133
134
135
136


137
138
139
140
141

142
143

144
145
146
147
148
149
150


151
152
153
154
155

156
157


158
159
160
161
162
163
164
165


166
167
168


169
170
171
172
173
174


175
176
177


178
179
180
181
182
183


184
185
186

187
188
189
190


191
192
193

194
195
196
197
198


199
200
201
202
203


204
205
206
207
208
209
210
211


212
213
214
215
216


217
218
219
220
221
222
223


224
225
226



227
228
229
230
231
232
233


234
235
236

237
238
239
240
241
242
243
244







-
-
+
+








-
-
+
+

-
-
-
+
+
+




-
-
+
+

-
+

-
+



-
-
+
+

-
+



-
-
+
+

-
-
+
+



-
-
+
+

-
-
+
+



-
-
+
+

-
+



-
-
+
+

-
-
+
+




-
-
+
+

-
-
+
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+




-
-
+
+



-
+

-
+






-
-
+
+



-
+

-
-
+
+






-
-
+
+

-
-
+
+




-
-
+
+

-
-
+
+




-
-
+
+

-
+



-
-
+
+

-
+




-
-
+
+



-
-
+
+






-
-
+
+



-
-
+
+





-
-
+
+

-
-
-
+
+
+




-
-
+
+

-
+







extern "C" {
#endif
extern void of_log(OFConstantString*, ...);
#ifdef __cplusplus
}
#endif

/**
 * \brief A class which provides functions to read, write and manipulate files.
/*!
 * @brief A class which provides functions to read, write and manipulate files.
 */
@interface OFFile: OFSeekableStream
{
	int  fd;
	BOOL closable;
	BOOL atEndOfStream;
}

/**
 * \brief Creates a new OFFile with the specified path and mode.
/*!
 * @brief Creates a new OFFile with the specified path and mode.
 *
 * \param path The path to the file to open as a string
 * \param mode The mode in which the file should be opened as a string
 * \return A new autoreleased OFFile
 * @param path The path to the file to open as a string
 * @param mode The mode in which the file should be opened as a string
 * @return A new autoreleased OFFile
 */
+ (instancetype)fileWithPath: (OFString*)path
			mode: (OFString*)mode;

/**
 * \brief Creates a new OFFile with the specified file descriptor.
/*!
 * @brief Creates a new OFFile with the specified file descriptor.
 *
 * \param fileDescriptor A file descriptor, returned from for example open().
 * @param fileDescriptor A file descriptor, returned from for example open().
 *			 It is not closed when the OFFile object is deallocated!
 * \return A new autoreleased OFFile
 * @return A new autoreleased OFFile
 */
+ (instancetype)fileWithFileDescriptor: (int)fileDescriptor;

/**
 * \brief Returns the path fo the current working directory.
/*!
 * @brief Returns the path fo the current working directory.
 *
 * \return The path of the current working directory
 * @return The path of the current working directory
 */
+ (OFString*)currentDirectoryPath;

/**
 * \brief Checks whether a file exists at the specified path.
/*!
 * @brief Checks whether a file exists at the specified path.
 *
 * \param path The path to check
 * \return A boolean whether there is a file at the specified path
 * @param path The path to check
 * @return A boolean whether there is a file at the specified path
 */
+ (BOOL)fileExistsAtPath: (OFString*)path;

/**
 * \brief Checks whether a directory exists at the specified path.
/*!
 * @brief Checks whether a directory exists at the specified path.
 *
 * \param path The path to check
 * \return A boolean whether there is a directory at the specified path
 * @param path The path to check
 * @return A boolean whether there is a directory at the specified path
 */
+ (BOOL)directoryExistsAtPath: (OFString*)path;

/**
 * \brief Creates a directory at the specified path.
/*!
 * @brief Creates a directory at the specified path.
 *
 * \param path The path of the directory
 * @param path The path of the directory
 */
+ (void)createDirectoryAtPath: (OFString*)path;

/**
 * \brief Creates a directory at the specified path.
/*!
 * @brief Creates a directory at the specified path.
 *
 * \param path The path of the directory
 * \param createParents Whether to create the parents of the directory
 * @param path The path of the directory
 * @param createParents Whether to create the parents of the directory
 */
+ (void)createDirectoryAtPath: (OFString*)path
		createParents: (BOOL)createParents;

/**
 * \brief Returns an array with the files in the specified directory.
/*!
 * @brief Returns an array with the files in the specified directory.
 *
 * \param path The path of the directory
 * \return An array of OFStrings with the files at the specified path
 * @param path The path of the directory
 * @return An array of OFStrings with the files at the specified path
 */
+ (OFArray*)filesInDirectoryAtPath: (OFString*)path;

/**
 * \brief Changes the current working directory.
/*!
 * @brief Changes the current working directory.
 *
 * \param path The new directory to change to
 * @param path The new directory to change to
 */
+ (void)changeToDirectoryAtPath: (OFString*)path;

/**
 * \brief Returns the size of the specified file.
/*!
 * @brief Returns the size of the specified file.
 *
 * \return The size of the specified file
 * @return The size of the specified file
 */
+ (off_t)sizeOfFileAtPath: (OFString*)path;

/**
 * \brief Returns the date of the last modification of the file.
/*!
 * @brief Returns the date of the last modification of the file.
 *
 * \return The date of the last modification of the file
 * @return The date of the last modification of the file
 */
+ (OFDate*)modificationDateOfFileAtPath: (OFString*)path;

#ifndef _PSP
/**
 * \brief Changes the mode of a file.
/*!
 * @brief Changes the mode of a file.
 *
 * Only changes read-only flag on Windows.
 *
 * \param path The path to the file of which the mode should be changed as a
 * @param path The path to the file of which the mode should be changed as a
 *	       string
 * \param mode The new mode for the file
 * @param mode The new mode for the file
 */
+ (void)changeModeOfFileAtPath: (OFString*)path
			  mode: (mode_t)mode;
#endif

#if !defined(_WIN32) && !defined(_PSP)
/**
 * \brief Changes the owner of a file.
/*!
 * @brief Changes the owner of a file.
 *
 * Not available on Windows.
 *
 * \param path The path to the file of which the owner should be changed as a
 * @param path The path to the file of which the owner should be changed as a
 *	       string
 * \param owner The new owner for the file
 * \param group The new group for the file
 * @param owner The new owner for the file
 * @param group The new group for the file
 */
+ (void)changeOwnerOfFileAtPath: (OFString*)path
			  owner: (OFString*)owner
			  group: (OFString*)group;
#endif

/**
 * \brief Copies a file.
/*!
 * @brief Copies a file.
 *
 * \param source The file to copy
 * \param destination The destination path
 * @param source The file to copy
 * @param destination The destination path
 */
+ (void)copyFileAtPath: (OFString*)source
		toPath: (OFString*)destination;

/**
 * \brief Renames a file.
/*!
 * @brief Renames a file.
 *
 * \param source The file to rename
 * \param destination The new name
 * @param source The file to rename
 * @param destination The new name
 */
+ (void)renameFileAtPath: (OFString*)source
		  toPath: (OFString*)destination;

/**
 * \brief Deletes a file.
/*!
 * @brief Deletes a file.
 *
 * \param path The path to the file of which should be deleted as a string
 * @param path The path to the file of which should be deleted as a string
 */
+ (void)deleteFileAtPath: (OFString*)path;

/**
 * \brief Deletes an empty directory.
/*!
 * @brief Deletes an empty directory.
 *
 * \param path The path to the directory which should be deleted as a string
 * @param path The path to the directory which should be deleted as a string
 */
+ (void)deleteDirectoryAtPath: (OFString*)path;

#ifndef _WIN32
/**
 * \brief Creates a hard link for a file.
/*!
 * @brief Creates a hard link for a file.
 *
 * Not available on Windows.
 *
 * \param source The path to the file of which should be linked as a string
 * \param destination The path to where the file should be linked as a string
 * @param source The path to the file of which should be linked as a string
 * @param destination The path to where the file should be linked as a string
 */
+ (void)linkFileAtPath: (OFString*)source
		toPath: (OFString*)destination;
#endif

#if !defined(_WIN32) && !defined(_PSP)
/**
 * \brief Creates a symbolink link for a file.
/*!
 * @brief Creates a symbolink link for a file.
 *
 * Not available on Windows.
 *
 * \param source The path to the file of which should be symlinked as a string
 * \param destination The path to where the file should be symlinked as a string
 * @param source The path to the file of which should be symlinked as a string
 * @param destination The path to where the file should be symlinked as a string
 */
+ (void)symlinkFileAtPath: (OFString*)source
		   toPath: (OFString*)destination;
#endif

/**
 * \brief Initializes an already allocated OFFile.
/*!
 * @brief Initializes an already allocated OFFile.
 *
 * \param path The path to the file to open as a string
 * \param mode The mode in which the file should be opened as a string
 * \return An initialized OFFile
 * @param path The path to the file to open as a string
 * @param mode The mode in which the file should be opened as a string
 * @return An initialized OFFile
 */
- initWithPath: (OFString*)path
	  mode: (OFString*)mode;

/**
 * \brief Initializes an already allocated OFFile.
/*!
 * @brief Initializes an already allocated OFFile.
 *
 * \param fileDescriptor A file descriptor, returned from for example open().
 * @param fileDescriptor A file descriptor, returned from for example open().
 *			 It is not closed when the OFFile object is deallocated!
 */
- initWithFileDescriptor: (int)fileDescriptor;
@end

#ifdef __cplusplus
extern "C" {