- Use the full file path when calling stat().
- Check the return status of stat() before using the "struct stat".