Get the number of bytes of the file through the stat function in linux

size_t filesize(const char* file_name)
{
    size_t filesize = _maxFileSize+1;
    if (file_name != NULL)
    {
        struct stat statbuff;
        if(stat(file_name, &statbuff) == 0)
        {
            filesize = statbuff.st_size;
        }
    }

    return filesize;
}

Guess you like

Origin blog.csdn.net/modi000/article/details/114264952