djw has asked for the wisdom of the Perl Monks concerning the following question:
I have written a small application to collect file/path information recursively from a root path given during execution. I collect this information of each file (using File::stat and File::Find):
I store that information in a mysql database. For some reason it is returning a negative value from File::stat's size method on specific files (test system is win32 and the same files are negative when I run the program again). One of the files is a system file (pagefile.sys), but the rest are simply mpeg's. Each file is over 500MB in size. There are other files collected that record the correct size and are 500MB or greater, so it doesn't seem to be a file size problem. There are also other files in the same directories as the problem files and have properly recorded file sizes. There isn't a permission problem on these files.
- current directory
- file size (size)
- file create time (ctime)
- file modify time (mtime)
- file access time (atime)
I store that information in a mysql database. For some reason it is returning a negative value from File::stat's size method on specific files (test system is win32 and the same files are negative when I run the program again). One of the files is a system file (pagefile.sys), but the rest are simply mpeg's. Each file is over 500MB in size. There are other files collected that record the correct size and are 500MB or greater, so it doesn't seem to be a file size problem. There are also other files in the same directories as the problem files and have properly recorded file sizes. There isn't a permission problem on these files.
Here is a quick snippet:
Here is what the data looks like in the db:
Any suggestions on how I should solve this?
Thanks,
djw
Then I just iterate over the hash to enter all the data into the database (no modification or calculations etc). Also, there are no errors or warnings during or after execution.use File::stat qw(:FIELDS ); use File::Find qw( finddepth ); # stuff... finddepth \&gatherData, $dir; # stuff... sub gatherData { if (-f) { stat($_); # ----------- # get the current directory # and file names my $cdir = $File::Find::dir; my $file = $_; # ----------- # put that into our data # hash for input later $data{$cdir}{$file}{size} = $st_size; $data{$cdir}{$file}{ctime} = $st_ctime; $data{$cdir}{$file}{mtime} = $st_mtime; $data{$cdir}{$file}{atime} = $st_atime; } }
Here is what the data looks like in the db:
I have around 194 K files listed in the files table (from two different systems), and all of these files are from the same system.mysql> select file_id, file, size from files where size < 0; +---------+--------------+-------------+ | file_id | file | size | +---------+--------------+-------------+ | 635609 | fooo 3.mpg | -773913892 | | 635608 | baaar 1.mpg | -529282490 | | 635603 | foooo 3.mpg | -2035912248 | | 611851 | pagefile.sys | -2147483648 | +---------+--------------+-------------+ 4 rows in set (0.32 sec)
Any suggestions on how I should solve this?
Thanks,
djw
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: File::stat's size method returns negative values
by vladb (Vicar) on May 06, 2003 at 21:19 UTC | |
by djw (Vicar) on May 06, 2003 at 21:32 UTC | |
by leriksen (Curate) on May 07, 2003 at 00:55 UTC | |
Re: File::stat's size method returns negative values
by BrowserUk (Patriarch) on May 07, 2003 at 03:34 UTC | |
Re: File::stat's size method returns negative values
by PodMaster (Abbot) on May 07, 2003 at 08:56 UTC | |
by djw (Vicar) on May 07, 2003 at 14:14 UTC | |
Re: File::stat's size method returns negative values
by djw (Vicar) on May 07, 2003 at 21:46 UTC |
Back to
Seekers of Perl Wisdom