I am using _stati64() in my file manager so that I can get the size of files over 4gb.
My code looks normal:
struct _stati64 buf;
_stati64(ep->d_name, &buf);
The thing is, sometimes _stati64 works properly, sometimes I get huge values. I even checked with gdb, by doing print buf and still get bad values, so the problem doesn’t seem to be with my code.
Did anyone experience something similar?
You need to check the return value of
_stati64. If it’s not 0, you won’t have valid results.If your actual code does check the return value, the error is most likely that you are somehow corrupting the structure after
_stati64returns.The last possibility is that the “bad values” you get are actually valid and good values. I’ll update my answer if you update the question with what values you are getting.