[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to get the size of large files ?

From: Leo Butler
Subject: Re: how to get the size of large files ?
Date: Thu, 22 Sep 2011 11:03:58 -0400
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.2 (gnu/linux)

vatko <address@hidden> writes:

> Hi,
> I had a code in matlab that needed to know the exact size of some data file
> at a certain point. I used the function s = dir(filename) and read the file
> size in s.bytes. But this does not work in octave with very large files. I
> have a file that is ~3.4Go and dir tells me that the file does not exist. I
> also tried stat(), but it gives me an empty array. But both function work
> with small files of a few Mo.
> Is there any other way I can get the size of a file ?
> thanks

You can use the system command, e.g.

function s = fsize(file)
 [x,s]=system(sprintf("ls -s --block-size=1 %s",file));
 s=strtok(s," ");

This returns a string containing the file size. You can use `eval' on
that string to get a float.

Note that what you are seeing is a bug in the way that octave is
populating the structure in a call to stat. Leo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]