1 |
|
/* |
2 |
|
* extfs_unix.cpp - MacOS file system for access native file system access, Unix specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2000 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
85 |
|
uint32 type; |
86 |
|
uint32 creator; |
87 |
|
uint16 flags; |
88 |
< |
uint16 pad0; |
88 |
> |
uint8 pad0[22]; // total size: 32 bytes to match the size of FInfo+FXInfo |
89 |
|
}; |
90 |
|
|
91 |
|
static void make_helper_path(const char *src, char *dest, const char *add, bool only_dir = false) |
226 |
|
|
227 |
|
// Read file |
228 |
|
finf_struct finf; |
229 |
< |
if (read(fd, &finf, sizeof(finf_struct)) == sizeof(finf_struct)) { |
229 |
> |
if (read(fd, &finf, sizeof(finf_struct)) >= 8) { |
230 |
|
|
231 |
|
// Type/creator are in Finder info file, return them |
232 |
|
type = ntohl(finf.type); |
259 |
|
return; |
260 |
|
|
261 |
|
// Read file |
262 |
< |
finf_struct finf = {0, 0, DEFAULT_FINDER_FLAGS, 0}; |
262 |
> |
finf_struct finf; |
263 |
> |
finf.flags = DEFAULT_FINDER_FLAGS; |
264 |
> |
memset(&finf, 0, sizeof(finf_struct)); |
265 |
|
read(fd, &finf, sizeof(finf_struct)); |
266 |
|
|
267 |
|
// Set Finder flags |
290 |
|
|
291 |
|
// Read Finder flags |
292 |
|
finf_struct finf; |
293 |
< |
if (read(fd, &finf, sizeof(finf_struct)) == sizeof(finf_struct)) |
293 |
> |
if (read(fd, &finf, sizeof(finf_struct)) >= 10) |
294 |
|
flags = ntohs(finf.flags); |
295 |
|
|
296 |
|
// Close file |
305 |
|
return; |
306 |
|
|
307 |
|
// Read file |
308 |
< |
finf_struct finf = {0, 0, DEFAULT_FINDER_FLAGS, 0}; |
308 |
> |
finf_struct finf; |
309 |
> |
memset(&finf, 0, sizeof(finf_struct)); |
310 |
> |
finf.flags = DEFAULT_FINDER_FLAGS; |
311 |
|
read(fd, &finf, sizeof(finf_struct)); |
312 |
|
|
313 |
|
// Set Finder flags |
352 |
|
|
353 |
|
/* |
354 |
|
* Read "length" bytes from file to "buffer", |
355 |
< |
* returns number of bytes read (or 0) |
355 |
> |
* returns number of bytes read (or -1 on error) |
356 |
|
*/ |
357 |
|
|
358 |
< |
size_t extfs_read(int fd, void *buffer, size_t length) |
358 |
> |
ssize_t extfs_read(int fd, void *buffer, size_t length) |
359 |
|
{ |
356 |
– |
errno = 0; |
360 |
|
return read(fd, buffer, length); |
361 |
|
} |
362 |
|
|
363 |
|
|
364 |
|
/* |
365 |
|
* Write "length" bytes from "buffer" to file, |
366 |
< |
* returns number of bytes written (or 0) |
366 |
> |
* returns number of bytes written (or -1 on error) |
367 |
|
*/ |
368 |
|
|
369 |
< |
size_t extfs_write(int fd, void *buffer, size_t length) |
369 |
> |
ssize_t extfs_write(int fd, void *buffer, size_t length) |
370 |
|
{ |
368 |
– |
errno = 0; |
371 |
|
return write(fd, buffer, length); |
372 |
|
} |
373 |
|
|