Finding the size of a large file

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Finding the size of a large file

    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);
    }
    John N. Guest

  2. Similar Questions and Discussions

    1. PDF file size too large...
      All, I work in an agency where for the past 10 years we have used Pagemaker for all of our literature. We have created PDF's from PM for use on our...
    2. Very Large Artboard / Document Size Problems and large content size
      Hi, Im currently trying to create a design for a box that is 18" X 18" X 18". I have never worked on anything this large before. THe image is...
    3. large print file size
      Help. Why would a +/- 3 mb indesign cs file blow up to 17 mb when printing to HP 5p for proofing purposes. Never experienced this in early versions.
    4. Illustrator CS files with large linked files results in large file size
      If I place a large linked Photoshop 7 file (.psd or.eps), say 36 MB, in Illustrator CS and save without embedding the file it takes ages to save and...
    5. recursively finding file size/timestamp on a Mac / Solaris
      Hi, This is wat I'm doing... but its not working :-( find (\&wanted,"$Root"); print OUT ' </table> <p>&nbsp;</p> </body>
  3. #2

    Default Re: Finding the size of a large file

    "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
    Michael P. Broida Guest

  4. #3

    Default Re: Finding the size of a large file

    John N. <jnokes1@yahoo.com> 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?" [url]http://www.aglami.com/tpfaq.html[/url]
    "Meanings are another story." [url]http://www.ifas.org/wa/glossolalia.html[/url]
    Nicholas Dronen Guest

  5. #4

    Default Re: Finding the size of a large file

    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.

    Run a series of searches for information pertaining to large files
    under Solaris. Related topics would include,

    32 bit versus 64 bit
    compiling perl for Solaris
    solaris large file utilities

    This search string will return a lot of information.
    It is up to you to decide which information meets
    your specific needs.

    solaris large file perl


    [url]http://www.netsys.com/cgi-bin/man2html?largefile(5[/url])


    Purl Gurl
    Purl Gurl Guest

  6. #5

    Default Re: Finding the size of a large file

    Purl Gurl wrote:
    > John N. wrote:
    (snipped)
    > [url]http://www.netsys.com/cgi-bin/man2html?largefile(5[/url])

    You may need to copy and paste this link. Mozilla does
    not include the final parenthesis in the hyperlink.


    Purl Gurl
    Purl Gurl Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139