From 7c24e9a9b02b04dcaf9507acb94091ea70a2c02d Mon Sep 17 00:00:00 2001 From: Xavi Del Campo Date: Fri, 31 Jan 2020 10:32:23 +0100 Subject: Imported pristine psxsdk-20190410 from official repo --- libpsx/src/libc/stat.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 libpsx/src/libc/stat.c (limited to 'libpsx/src/libc/stat.c') 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 +#include +#include +#include + +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; +} -- cgit v1.2.3