Get the file size using ftell() and fseek() functions in the Ring programming language

Hello

The next function can be used to get the file size without reading the file!

func getFileSize fp
       C_FILESTART = 0
       C_FILEEND = 2
       fseek(fp,0,C_FILEEND)
       nFileSize = ftell(fp)
       fseek(fp,0,C_FILESTART)
       return nFileSize

Note : the previous function take the fp (file pointer) as parameter

we get the fp from opening the file using fopen() function

fp = fopen(“filename”,”r”)

see  “File Size : ” + getFileSize(fp) + nl

Another solution (Read the file)

see len(read(“filename”))

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s