Dear Niel,

So the implication of this is that php cant (be trusted to) handled binary
files properly under windows?

While once step debugging with VC++ to see what fgets() returns as EOF. I
found it to be equal to -1. I don't remember if this was in binary or text
mode, but I think it was binary mode.


Regarding the EOF with Unix files, I am not quite sure how it works, but the
file size information is stored in a structure called 'icommon', so it would
make sense to read the info from there, and then just send and EOF to the
"application" when the file position pointer has reached that # of read
bytes. But to know for sure I would need to check the UNIX file system's
kernel source code, but I really don't have the time left for doing those
funny things today - actually I guess I would need to do at least some work
today to. :)

Cheers,

        /Anders - who was tempted to sporadically insert some ctrl-Z in this
message. :)

>-----Original Message-----
>From: DL Neil [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, February 14, 2002 2:04 PM
>To: Svensson, B.A.T. (HKG); [EMAIL PROTECTED]
>Cc: 'alain'
>Subject: Re: [PHP-WIN] Re: Searching MS Word Docs
>
>
>Sorry B.A.T,
>
>Alain's quote is taken directly from 
>http://www.php.net/manual/en/function.fopen.php
>
>Using/not "b" does make a difference under Windows - haven't 
>tested it under *nix!
>
>The 'end' of a Windows file can be defined in two ways: an 
>ASCII file ends with CTRL+Z, a 'binary' file ends
>where the header/catalog entry says so (not sure if that 
>terminology has 'traveled' properly). Somewhat
>obviously, the reason for the latter is that the ASCII code 
>for CTRL+Z may coincidentally appear within the
>middle of some binary digit (where it doesn't mean either 
>CTRL-Z or eof). Does *nix take filesizes from the
>catalog/file header information? and only there?
>
>Regards,
>=dn
>
>
>> >From the manual - Last thing to read ;)
>> >"Note: The mode may contain the letter 'b'. This is useful only on
systems
>> >which differentiate between binary and text files (i.e. Windows. It's
>> >useless on Unix). If not needed, this will be ignored. "
>>
>> If UNIX system doesn't difference between binary and text 
>files, how are for
>> ex
>>
>> 'char *fgets()' respectively 'char *gets()'
>>
>> supposed to be working then?
>>
>> When opening a file in binary mode (b) Unix and MS Windows 
>behaves more or
>> less the same, on the other hand when opening a file in text 
>write mode (w
>> or a) then UNIX might differ from MS Windows. I've noticed 
>that MS VC++
>> appends an ctrl-Z on the end of text files while writing to 
>them. If Borland
>> C++ does the same, I don't know. But as far as my limited 
>knowledge extends,
>> neither CC, cc, gcc or g++ does in this behavior.
>>
>> Conclusion:
>>
>> Opening a file in binary mode works more or less the same on UNIX and
>> Windows, but text mode works different on the both systems.
>
>=dn
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to