in reply to Portable filesize check? (Win32)

then it seems like '-s' reports wrong filesize (maybe \r\n is counted as one character?)
No. \r\n is not counted as one character. In my experience, the value returned by '-s' always agrees with that reported by the DIR command. Do a little test of that in isolation to convince yourself.

Replies are listed 'Best First'.
Re^2: Portable filesize check? (Win32)
by Eyck (Priest) on Mar 10, 2005 at 09:50 UTC
    As I said, the size reported by '-s' agrees with the one reported by dir.

    But 'dir' is not omnipotent, and there are things like sparse, encrypted and compressed files, where there's no obvious size to report. Check ls command manual, it's got myriad of switches for a reason.

    Problem was too much magic in perl file handling (or rather my lack of knowledge on that subject), and binmode fixed that.

      there are things like sparse, encrypted and compressed files, where there's no obvious size to report
      An operating system should not know anything about the contents of a file. What it should know is how many bytes on a disk that file occupies. So, the sparsity, encryptedness, or compressedness should not hinder the OS from knowing how many bytes that files takes up on disk.

      thor

      Feel the white light, the light within
      Be your own disciple, fan the sparks of will
      For all of us waiting, your kingdom will come