[BACK]Return to dirops.pm CVS log [TXT][DIR] Up to [local] / wpscripts / wpbackup

Annotation of wpscripts/wpbackup/dirops.pm, Revision 1.1

1.1     ! yason       1: #!/usr/bin/perl
        !             2: #
        !             3: # Contains directory operations (walkthrough etc.)
        !             4: #
        !             5:
        !             6: package dirops;
        !             7:
        !             8: our $SPOOL = "/usr/backup/spool_zayavki";
        !             9: our $IMAGE = "/usr/backup/images/zayavki";
        !            10: our $SIZE_MIN = 4294967296;    # 4.00 GB (stands for 4.00 * 1024 ^ 3)
        !            11: our $SIZE_MAX = 4563402752;    # 4.25 GB (stands for 4.25 * 1024 ^ 3)
        !            12:
        !            13: our @allfiles; # static array to keep files
        !            14: our $offset = 0;
        !            15: our $f_sizeof;
        !            16: our $a_sizeof = 0;
        !            17: our $a_count = 0;
        !            18: our @a;
        !            19:
        !            20: sub
        !            21: walkthrough()
        !            22: {
        !            23: #    chdir($SPOOL);
        !            24:     my @dirents = `ls -m $SPOOL`;
        !            25:     my @str;
        !            26:
        !            27:     for(my $i = 0; $i< scalar(@dirents); $i++)
        !            28:     {
        !            29:        chomp($dirents[$i]);
        !            30:
        !            31:        @str =  split(', ', $dirents[$i]);
        !            32:
        !            33:        push @allfiles, @str;
        !            34:
        !            35:     }
        !            36:
        !            37: }
        !            38:
        !            39:
        !            40: sub
        !            41: getnextblk()
        !            42: {
        !            43:     $a_sizeof = 0;
        !            44:     @a = ();
        !            45:
        !            46:     return( () ) if($offset == scalar(@allfiles));
        !            47:
        !            48:     for(my $i = $offset; $i < scalar(@allfiles); $i++ )
        !            49:     {
        !            50:            $f_sizeof = -s "$SPOOL/$allfiles[$i]";
        !            51:            # check sizes
        !            52:            if( $f_sizeof <= $SIZE_MAX - $a_sizeof)
        !            53:            {
        !            54:                $a_sizeof += $f_sizeof;
        !            55:                $a_count++;
        !            56:
        !            57:                push @a, "$SPOOL/$allfiles[$i]";
        !            58:            }
        !            59:            else
        !            60:            {
        !            61:                # $SIZE_MAX exceeded
        !            62:                #
        !            63:                # really don't assume BIG files
        !            64:                #
        !            65:                $offset = $i;
        !            66:
        !            67:                return(@a);
        !            68:            }
        !            69:     }
        !            70:
        !            71:     if($a_sizeof < $SIZE_MIN )
        !            72:     {
        !            73:        return( ( ) );
        !            74:        #NOTREACHED
        !            75:     }
        !            76:
        !            77:     return(@a);
        !            78: }
        !            79:
        !            80:
        !            81: return(1);

CVSweb