ObjFW  Check-in [c4f5d6f491]

Overview
Comment:Win32 version of OFFile's +[filesInDirectoryAtPath:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c4f5d6f4915322e503219f0387c3730b88892c0ec3768f438faff0ec6de5a8c7
User & Date: js on 2010-04-15 17:19:42
Other Links: manifest | tags
Context
2010-04-17
10:35
Make resizing a private method instead of inlining. check-in: e870ea71ac user: js tags: trunk
2010-04-15
17:19
Win32 version of OFFile's +[filesInDirectoryAtPath:]. check-in: c4f5d6f491 user: js tags: trunk
08:43
Add +[createDirectoryAtPath:] to OFFile. check-in: 2ef0a01201 user: js tags: trunk
Changes

Modified src/OFFile.m from [b3c752e8de] to [fef21b43fd].

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
		return YES;

	return NO;
}

+ (void)createDirectoryAtPath: (OFString*)path
{

	if (mkdir([path cString], DIR_MODE))



		@throw [OFCreateDirectoryFailedException newWithClass: self
								 path: path];
}

+ (OFArray*)filesInDirectoryAtPath: (OFString*)path
{
	OFAutoreleasePool *pool;
	OFMutableArray *files;


	DIR *dir;
	struct dirent *dirent;

	files = [OFMutableArray array];

	if ((dir = opendir([path cString])) == NULL)
		@throw [OFOpenFileFailedException newWithClass: self
							  path: path
							  mode: @"r"];

	@try {
		pool = [[OFAutoreleasePool alloc] init];







>

>
>
>







|
>
>



<
<







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
		return YES;

	return NO;
}

+ (void)createDirectoryAtPath: (OFString*)path
{
#ifndef _WIN32
	if (mkdir([path cString], DIR_MODE))
#else
	if (mkdir([path cString]))
#endif
		@throw [OFCreateDirectoryFailedException newWithClass: self
								 path: path];
}

+ (OFArray*)filesInDirectoryAtPath: (OFString*)path
{
	OFAutoreleasePool *pool;
	OFMutableArray *files = [OFMutableArray array];

#ifndef _WIN32
	DIR *dir;
	struct dirent *dirent;



	if ((dir = opendir([path cString])) == NULL)
		@throw [OFOpenFileFailedException newWithClass: self
							  path: path
							  mode: @"r"];

	@try {
		pool = [[OFAutoreleasePool alloc] init];
169
170
171
172
173
174
175

































176
177
178
179
180
181
182
			[pool releaseObjects];
		}

		[pool release];
	} @finally {
		closedir(dir);
	}


































	return files;
}

+ (void)changeModeOfFile: (OFString*)path
		  toMode: (mode_t)mode
{







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
			[pool releaseObjects];
		}

		[pool release];
	} @finally {
		closedir(dir);
	}
#else
	HANDLE handle;
	WIN32_FIND_DATA fd;

	path = [path stringByAppendingString: @"\\*"];

	if ((handle = FindFirstFile([path cString], &fd)) ==
	    INVALID_HANDLE_VALUE)
		@throw [OFOpenFileFailedException newWithClass: self
							  path: path
							  mode: @"r"];

	@try {
		pool = [[OFAutoreleasePool alloc] init];

		do {
			OFString *file;

			if (!strcmp(fd.cFileName, ".") ||
			    !strcmp(fd.cFileName, ".."))
				continue;

			file = [OFString stringWithCString: fd.cFileName];
			[files addObject: file];

			[pool releaseObjects];
		} while (FindNextFile(handle, &fd));

		[pool release];
	} @finally {
		FindClose(handle);
	}
#endif

	return files;
}

+ (void)changeModeOfFile: (OFString*)path
		  toMode: (mode_t)mode
{