diff options
| author | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 10:32:23 +0100 |
|---|---|---|
| committer | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 10:32:23 +0100 |
| commit | 7c24e9a9b02b04dcaf9507acb94091ea70a2c02d (patch) | |
| tree | c28d0748652ad4b4222309e46e6cfc82c0906220 /libpsx/src/libc/stat.c | |
| parent | a2b7b6bb1cc2f4a3258b7b2dbc92399d151f864d (diff) | |
| download | psxsdk-7c24e9a9b02b04dcaf9507acb94091ea70a2c02d.tar.gz | |
Imported pristine psxsdk-20190410 from official repo
Diffstat (limited to 'libpsx/src/libc/stat.c')
| -rw-r--r-- | libpsx/src/libc/stat.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libpsx/src/libc/stat.c b/libpsx/src/libc/stat.c new file mode 100644 index 0000000..1c43b92 --- /dev/null +++ b/libpsx/src/libc/stat.c @@ -0,0 +1,31 @@ +#include <psx.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> + +int stat(const char *path, struct stat *sb) +{ + struct DIRENTRY dir_e; + + if(firstfile((char*)path, &dir_e) == NULL) + return -1; + + sb->st_size = dir_e.size; + + if(strncmp(path, "cdrom:", 6) == 0) + sb->st_blksize = 2048; + else if(strncmp(path, "bu00:", 5) == 0 || + strncmp(path, "bu10:", 5) == 0) + sb->st_blksize = 128; + else +// not a real blocksize, will be there just as a placeholder + sb->st_blksize = 1024; + + sb->st_blocks = + sb->st_size / sb->st_blksize; + + if(sb->st_size % sb->st_blksize) + sb->st_blocks++; + + return 0; +} |
