Now I have been doing this for about two hours, but could not find the answers that helped.
The definition of "stat", as indicated in the manpage, states that the st_ctime field exists.
struct stat { dev_t st_dev; ino_t st_ino; mode_t st_mode; nlink_t st_nlink; uid_t st_uid; gid_t st_gid; dev_t st_rdev; off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; time_t st_atime; time_t st_mtime; time_t st_ctime; };
However, this is not like my system, although I use gcc (which should behave according to the standard).
In fact, all time fields (atime, mtime, ctime) are missing, and therefore the structure contains some atim, mtim, and ctim values ββthat return the timepec value instead of the required time_t value.
Now my questions are:
- Why is this so? I may have included the wrong header, but I'm really sure it should be sys / stat.h.
- I did not find too much information about timespec, what is it and why is it back here?
- Even if I find a workaround, will that help m, or will any other system not be able to execute my code?
I am using Ubuntu 11.10 and gcc 4.6.1.
My code (partially):
struct stat file_info; time_t t; if( lstat( path, &file_info ) == 0 ) { struct tm* timeinfo; t = file_info.st_ctime; timeinfo = localtime( &t );
I would be very happy if you could help with this, I really did not know why I could not compile using the st_ctime field of my structure, and, as usual, gcc does not help much when it comes to talking about errors; -)
He probably should do something with C # include problems, but I cannot determine what.
source share