Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Finding the size of a large file

Reply
Thread Tools

Finding the size of a large file

 
 
John N.
Guest
Posts: n/a
 
      08-15-2003
I am new to Perl. I have a Sun box running Solaris 8 and the Perl that
comes with the OS.

I pulled some code off of Sun's site that searches a directory tree
and finds big files. When I run the program it works except that it
does not find files over 5 GB.

I have done a few things to trouble shoot the code and I found that it
fails in two places. On the line of "elsif ((-f _) && (! -l $path))"
the file fails the -f switch test. When I do a ls -l on the directory
it shows that the file is a normal file with the same rights as the
other files in the directory. Then I took "-f _" logic check out and
printed the result of the "$size = -s $path;" code and the -s returns
a blank for the size.

Do I have to do differant things with large files? Are there bugs or
limitations on the -f and -s switches? How do I make the code work?

Thanks for your help,

John

#
# scan throught the directory tree
#

&traverse('.');

sub traverse {
local($dir) = shift;
local($path);
unless (opendir(DIR, $dir)) {
warn "Can't open $dir\n";
closedir(DIR);
return;
}
foreach (readdir(DIR)) {
next if $_ eq '.' || $_ eq '..';
$path = "$dir/$_";
if ((-d $path) && (! -l $path)) { # non-symlink dir, enter it
&traverse($path);
} elsif ((-f _) && (! -l $path)) { # plain file, but not a
symlink
$size = -s $path; # get the size in bytes
$ksize = $size / 1000; # convert to megabytes
if ($size > $minsize) {
$age = -A $path; # get the age in days
printf "%9d Kilobytes %4d days
%s\n",$ksize,int($age),$path;
}
}
}
closedir(DIR);
}
 
Reply With Quote
 
 
 
 
Michael P. Broida
Guest
Posts: n/a
 
      08-15-2003
"John N." wrote:
>
> I am new to Perl. I have a Sun box running Solaris 8 and the Perl that
> comes with the OS.
>
> I pulled some code off of Sun's site that searches a directory tree
> and finds big files. When I run the program it works except that it
> does not find files over 5 GB.


The largest number that can be held in a 32-bit integer
(unsigned) is 4,294,967,295.

That's 4.29+ Gig. Since you mention 5GB in your post,
I'm thinking that the size is beyond what the code
can handle.

If I'm correct, then it's seeing that 5GB file as
being 5,000,000,000 - 4,294,967,295 = 705,032,705
or about 705MB. If you were searching for files
larger than 700MB, this one should still show up.
But if you're looking for files over 1GB, it won't.

Mike
 
Reply With Quote
 
 
 
 
Nicholas Dronen
Guest
Posts: n/a
 
      08-15-2003
John N. <(E-Mail Removed)> wrote:
JN> I am new to Perl. I have a Sun box running Solaris 8 and the Perl that
JN> comes with the OS.
JN>
JN> I pulled some code off of Sun's site that searches a directory tree
JN> and finds big files. When I run the program it works except that it
JN> does not find files over 5 GB.

JN> I have done a few things to trouble shoot the code and I found that it
JN> fails in two places. On the line of "elsif ((-f _) && (! -l $path))"
JN> the file fails the -f switch test. When I do a ls -l on the directory
JN> it shows that the file is a normal file with the same rights as the
JN> other files in the directory. Then I took "-f _" logic check out and
JN> printed the result of the "$size = -s $path;" code and the -s returns
JN> a blank for the size.

JN> Do I have to do differant things with large files? Are there bugs or
JN> limitations on the -f and -s switches? How do I make the code work?

Is there any mention of large files in the output of perl -V:ccflags?

Regards,

Nicholas

--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
median of large data set (from large file) friend.05@gmail.com Perl Misc 5 04-02-2009 04:06 AM
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Finding new / dupe files on large file system Anonymous Coward Computer Support 2 09-25-2004 05:19 AM
[Urgent] Is there a size limit on returning a large dataset or a large typed array from web service? Ketchup ASP .Net Web Services 1 05-25-2004 10:11 AM



Advertisments