ObjFW  Check-in [6bcf417920]

Overview
Comment:Add +[OFFile sizeOfFile:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6bcf417920708b27dba81ef27e93880a1f83b755e8dec7c14dddba6cbd10e441
User & Date: js on 2012-03-08 23:20:27
Other Links: manifest | tags
Context
2012-03-12
11:01
Remove +[OFArray arrayWithCArray:] as it is pretty useless. check-in: 32f7b1390a user: js tags: trunk
2012-03-08
23:20
Add +[OFFile sizeOfFile:]. check-in: 6bcf417920 user: js tags: trunk
18:04
OFHTTPRequest: Handle OFInvalidEncodingException due to incorrect reply. check-in: 59a1fd63eb user: js tags: trunk
Changes

Modified src/OFFile.h from [c75eb39d48] to [06cd3c5eac].

106
107
108
109
110
111
112







113
114
115
116
117
118
119
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126







+
+
+
+
+
+
+







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

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

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

Modified src/OFFile.m from [73d7458af5] to [7a546860fc].

368
369
370
371
372
373
374














375
376
377
378
379
380
381
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395







+
+
+
+
+
+
+
+
+
+
+
+
+
+







		@throw [OFChangeFileModeFailedException
		    exceptionWithClass: self
				  path: path
				  mode: mode];
# endif
}
#endif

+ (off_t)sizeOfFile: (OFString*)path
{
	struct stat s;

	if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    &s) == -1)
		/* FIXME: Maybe use another exception? */
		@throw [OFOpenFileFailedException exceptionWithClass: self
								path: path
								mode: @"r"];

	return s.st_size;
}

+ (OFDate*)modificationDateOfFile: (OFString*)path
{
	struct stat s;

	if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    &s) == -1)