From: ahoward Date: 2003-01-29T02:22:10+09:00 Subject: Re: FileTest.size? vs du -b On Tue, 28 Jan 2003, Curious Person wrote: > ahoward wrote in > news:Pine.LNX.4.33.0301281641050.8727-100000@eli.fsl.noaa.gov: > > > > > > so accurate depends on you viewpoint : if you are concerned about the > > total size of files on disk the du is more accurate, if you simply > > want to know the size of a file to, for example, read it into a > > malloc'd array then stat (FileTest.size) is the way to go. > > > Well, what I eventually want to do is have a script that fills CDRs up to > capacity for mkisofs to burn (but not over). Therefore, I need a way to > measure size to ensure a good fit on the disc. I'm not sure which would be > better; blocks or bytes, though. Would FileTest.size would be the most > appropriate method to use? i'm pretty sure that summing FileTest.size for all files bound for CDR would be the correct way to go, at least that's how i programmed some backups here at work. i don't really know how the iso filesystem works regarding block size (or if the concept even applies) but, as lyle pointed out, filesystems do differ. i think that total_size = 0 files.map {|f| total_size += f.size} if (total_size < CDR.size) #burn end will work. -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================