gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > File Status

#151716 - darkchild - Mon Mar 03, 2008 9:49 pm

Hello, here I am with another noobish question XD

well, let me go straight to the point xD

I wanna get file Stats, I have a line of code:

Code:
struct stat st;


if I am not mistaken, this creates a structure for status of the file opened, but how do I access them?
and what status can I get from this?
can I get stuff as FileSize and stuff?

#151727 - tepples - Tue Mar 04, 2008 12:01 am

darkchild wrote:
I wanna get file Stats, I have a line of code:

Code:
struct stat st;


if I am not mistaken, this creates a structure for status of the file opened, but how do I access them?
and what status can I get from this?
can I get stuff as FileSize and stuff?

man stat

Untested:
Code:
rv = stat(filename, &st);
if (rv >= 0) {
  fileSize = st.st_size;
} else {
  iprintf("Could not stat '%s': %s\n", filename, strerror(errno))
}

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.