in reply to Re: Limit a filesize
in thread Limit a filesize

I did a short experement with a text file I have, basicaly I told it to print out the size of the file, and then open it, read it and print the length... they didn't match. I'll admit, I'm currently stuck on Win32, but the file was saved in UNIX (I love TextPad). So I don't quite know what to make of that, or did I misunderstand what you were saying?



"Weird things happen, get used to it."

Flame ~ Lead Programmer: GMS

Replies are listed 'Best First'.
Re: Re: Re: Limit a filesize
by belg4mit (Prior) on Apr 09, 2002 at 02:57 UTC
    You did misunderstand, or I was unclear. First and foremost the size of a file is not the same as the size of it's contents (especially on some filesystems). But for all but the strictest of purposes it's close enough. What I suggested was something like:
    #About to append $message, do we have enough room? if( -s $file + length($message) > $maxSize ){ #do magic here }

    --
    perl -pe "s/\b;([mnst])/'\1/mg"

      Oh, I think I understand now, basically, it's just a good approximation, not precise. Ok, thanks. I'll see what I can do with the information you guys gave me (including those of you in other sub-threads.)

      Thanks



      "Weird things happen, get used to it."

      Flame ~ Lead Programmer: GMS