Seongsu Lee <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> I want to get the size of a block device by ftell(). I found that I
> can get
> the size of a device by seek() and tell() in Python. But not in C.
> 
> What is difference between them? How can I get the size of a block
> device by ftell()?

[snip]
>         fp = fopen(d, "r");
>         fseek(fp, 0L, SEEK_END);
>         l = ftell(fp);
>         fclose(fp);
> 
>         return l;

> ---- # ./ftell_test
> 362031
> -1

You need to check the return values.  ftell is returning -1, which is an 
indicator that it failed.  If you were to print out errno, you could then 
look up why it's failing.  (Or, you could call perror(3) or strerror(3) 
to get it translated into text for you.)

> -----------------------------------------------------------------------
----
> # ./ftell_test.py
> 362031
> 120034091520

Or, if you convert the python version's output to hexadecimal and count 
the digits, you might figure out the proximate cause of your program's 
failure.

GH
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to