403 struct stat statbuf; |
403 struct stat statbuf; |
404 BAIL_IF_MACRO(stat(fname, &statbuf) < 0, strerror(errno), -1); |
404 BAIL_IF_MACRO(stat(fname, &statbuf) < 0, strerror(errno), -1); |
405 return statbuf.st_mtime; |
405 return statbuf.st_mtime; |
406 } /* __PHYSFS_platformGetLastModTime */ |
406 } /* __PHYSFS_platformGetLastModTime */ |
407 |
407 |
|
408 |
|
409 int __PHYSFS_platformStat(const char *filename, int *exists, PHYSFS_Stat *st) |
|
410 { |
|
411 struct stat statbuf; |
|
412 |
|
413 /* !!! FIXME: lstat()? */ |
|
414 if (stat(filename, &statbuf)) |
|
415 { |
|
416 if (errno == ENOENT) |
|
417 { |
|
418 *exists = 0; |
|
419 return 0; |
|
420 } /* if */ |
|
421 else |
|
422 { |
|
423 BAIL_MACRO(strerror(errno), -1); |
|
424 } /* else */ |
|
425 } /* if */ |
|
426 |
|
427 if (S_ISREG(statbuf.st_mode)) |
|
428 { |
|
429 st->filetype = PHYSFS_FILETYPE_REGULAR; |
|
430 st->filesize = statbuf.st_size; |
|
431 } /* if */ |
|
432 |
|
433 else if(S_ISDIR(statbuf.st_mode)) |
|
434 { |
|
435 st->filetype = PHYSFS_FILETYPE_DIRECTORY; |
|
436 st->filesize = 0; |
|
437 } /* else if */ |
|
438 |
|
439 else |
|
440 { |
|
441 st->filetype = PHYSFS_FILETYPE_OTHER; |
|
442 st->filesize = statbuf.st_size; |
|
443 } /* else */ |
|
444 |
|
445 st->modtime = statbuf.st_mtime; |
|
446 st->createtime = statbuf.st_ctime; |
|
447 st->accesstime = statbuf.st_atime; |
|
448 |
|
449 /* !!! FIXME: maybe we should just report full permissions? */ |
|
450 st->readonly = access(filename, W_OK); |
|
451 return 0; |
|
452 } /* __PHYSFS_platformStat */ |
|
453 |
408 #endif /* PHYSFS_PLATFORM_POSIX */ |
454 #endif /* PHYSFS_PLATFORM_POSIX */ |
409 |
455 |
410 /* end of posix.c ... */ |
456 /* end of posix.c ... */ |
411 |
457 |