Using NT registry calls to solve CR-LF issue with text
files.
Gunnar Degnbol
degnbol at danbbs.dk
Tue Feb 8 23:49:23 GMT 2000
At 08:20 07-02-2000 +1100, John E. Malmberg wrote:
>Beau Kuiper <ekuiperba at cc.curtin.edu.au> wrote:
> >
> > On Sun, 6 Feb 2000, John E. Malmberg wrote:
>
>Windows actually uses two methods of determining a file type. The first is
>a registry, and the second is to examine the first two bytes of the file for
>a signature. Some programs use the signature over the file type.
I have looked at how Windows determines MIME types. The url is
http://msdn.microsoft.com/workshop/networking/moniker/overview/appendix_a.asp.
It can be done using FindMimeFromData(), but it won't work. If the MIME
type can't be determined more precisely than 'text/plain' (after
considering the type reported by a web server, magic bytes, whether the
data looks like a binary or text, and the extension), and the file is
associated with an application, the type is set to
'application/octet-stream'. So, for example, a .C file will not be
reported as a text file if you have a C++ compiler. Nothing in the
registry indicates that it is a text file.
The reasoning behind this behaviour is amazing:
"As an example, this is necessary when downloading, among others, .bat and
.cmd files, which are plain text files, are frequently identified by the
server as 'text/plain', and have no associated MIME type in the registry.
Without the final check for an associated application, these would be
displayed in-pane, whereas the desired behavior is to launch the command
interpreter."
The Internet is just like your hard disk, or your LAN, so when you click on
a .BAT file in your integrated file manager/browser you will obviously want
to run it before reading it.
I guess this has been fixed many times over (once for each dangerous file
type).
>Remember the average user thinks all this stuff works by magic.
The average user should not be led to believe it is possible to
successfully ignore how computers work.
Gunnar
More information about the samba-technical
mailing list