www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Well, it's been a total failure

reply bearophile <bearophileHUGS lycos.com> writes:
Andrei Alexandrescu:

 I didn't know there is an executable attribute on Windows.

If you rename a txt file as .exe, if you click on it Windows tries to run it.
 This reminds me of the discussion of yesteryear - people 
 were complaining about C++ files in dmd having the .c extension, and the 
 right answer would have been to change the blessed thing to be like 
 everybody else has it, instead of finding arguments on why it worked the 
 way it was.

+1, despite there is more than one way to give suffix to C++ files. There is a bug report on this, not written by me. Having source code simple, clean, tidy, and readable is important for all open source projects, because that increases the probability of finding collaborators. Giving a sensible suffix to files is a starting point for that. Bye, bearophile
Sep 13 2010
next sibling parent reply Justin Johansson <no spam.com> writes:
On 14/09/2010 11:07 AM, bearophile wrote:
 Andrei Alexandrescu:

 I didn't know there is an executable attribute on Windows.

If you rename a txt file as .exe, if you click on it Windows tries to run it.
 This reminds me of the discussion of yesteryear - people
 were complaining about C++ files in dmd having the .c extension, and the
 right answer would have been to change the blessed thing to be like
 everybody else has it, instead of finding arguments on why it worked the
 way it was.

+1, despite there is more than one way to give suffix to C++ files. There is a bug report on this, not written by me. Having source code simple, clean, tidy, and readable is important for all open source projects, because that increases the probability of finding collaborators. Giving a sensible suffix to files is a starting point for that. Bye, bearophile

There is not a lot of use in creating your own "readable" file suffices (alla file extensions). Unless your file extension is known on the platform you are using then there may be no hope of reasonable opening your file with the requisite application on another platform. Say if your name was Robin, would you name your text files as .bat ? Holy Gotham (says Batman), am I to know what application to open that with? Cheers, Justin Johansson
Sep 15 2010
next sibling parent Justin Johansson <no spam.com> writes:
On 15/09/2010 10:38 PM, Justin Johansson wrote:
 There is not a lot of use in creating your own "readable" file suffices
 (alla file extensions). Unless your file extension is known on the
 platform you are using then there may be no hope of reasonable opening
 your file with the requisite application on another platform.

 Say if your name was Robin, would you name your text files as .bat ?

 Holy Gotham (says Batman), am I to know what application to open that with?

 Cheers,
 Justin Johansson

Of course the Penguin always know how to open a file ... especially for evil purposes :-)
Sep 15 2010
prev sibling next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Wednesday, September 15, 2010 06:08:49 Justin Johansson wrote:
 On 14/09/2010 11:07 AM, bearophile wrote:
 Andrei Alexandrescu:
 I didn't know there is an executable attribute on Windows.

If you rename a txt file as .exe, if you click on it Windows tries to run it.
 This reminds me of the discussion of yesteryear - people
 were complaining about C++ files in dmd having the .c extension, and the
 right answer would have been to change the blessed thing to be like
 everybody else has it, instead of finding arguments on why it worked the
 way it was.

+1, despite there is more than one way to give suffix to C++ files. There is a bug report on this, not written by me. Having source code simple, clean, tidy, and readable is important for all open source projects, because that increases the probability of finding collaborators. Giving a sensible suffix to files is a starting point for that. Bye, bearophile

There is not a lot of use in creating your own "readable" file suffices (alla file extensions). Unless your file extension is known on the platform you are using then there may be no hope of reasonable opening your file with the requisite application on another platform. Say if your name was Robin, would you name your text files as .bat ? Holy Gotham (says Batman), am I to know what application to open that with? Cheers, Justin Johansson

If you're on a non-Windows system, the mime-type becomes far more important than the extension. Most programs in Linux (and I believe MacOS X as well) don't care about the extension. They just look at the mime type. Extensions become almost entirely a thing for the user. So, whether your file is useable becomes more of an issue of known mime type than known extension. Still, you don't generally want to just be making up extensions. - Jonathan M davis
Sep 15 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Jonathan M Davis" <jmdavisProg gmx.com> wrote in message 
news:mailman.225.1284568096.858.digitalmars-d puremagic.com...
 If you're on a non-Windows system, the mime-type becomes far more 
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well) 
 don't care
 about the extension. They just look at the mime type. Extensions become 
 almost
 entirely a thing for the user. So, whether your file is useable becomes 
 more of
 an issue of known mime type than known extension. Still, you don't 
 generally
 want to just be making up extensions.

I didn't think unix file systems had a concept of mime type.
Sep 15 2010
next sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Nick Sabalausky wrote:
 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message=20
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...
 If you're on a non-Windows system, the mime-type becomes far more=20
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well) =


 don't care
 about the extension. They just look at the mime type. Extensions becom=


 almost
 entirely a thing for the user. So, whether your file is useable become=


 more of
 an issue of known mime type than known extension. Still, you don't=20
 generally
 want to just be making up extensions.

I didn't think unix file systems had a concept of mime type. =20

mime type and then choose the app associated to the mime type. Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Sep 15 2010
parent reply KennyTM~ <kennytm gmail.com> writes:
On Sep 16, 10 04:35, "Jérôme M. Berger" wrote:
 Nick Sabalausky wrote:
 "Jonathan M Davis"<jmdavisProg gmx.com>  wrote in message
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...
 If you're on a non-Windows system, the mime-type becomes far more
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well)
 don't care
 about the extension. They just look at the mime type. Extensions become
 almost
 entirely a thing for the user. So, whether your file is useable becomes
 more of
 an issue of known mime type than known extension. Still, you don't
 generally
 want to just be making up extensions.

I didn't think unix file systems had a concept of mime type.

mime type and then choose the app associated to the mime type. Jerome

Please don't confuse Unix with a distro.
Sep 15 2010
parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

KennyTM~ wrote:
 On Sep 16, 10 04:35, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Nick Sabalausky wrote:
 I didn't think unix file systems had a concept of mime type.

mime type and then choose the app associated to the mime type. Jerome

Please don't confuse Unix with a distro.

Which distro? I used the terms "Unix tools" because it transcends distributions and Unices. It is as true on Ubuntu as on *BSD or Solaris... Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Sep 16 2010
parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

J=C3=A9r=C3=B4me M. Berger wrote:
 KennyTM~ wrote:
 On Sep 16, 10 04:35, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Nick Sabalausky wrote:
 I didn't think unix file systems had a concept of mime type.




 mime type and then choose the app associated to the mime type.

         Jerome


Which distro? I used the terms "Unix tools" because it transcends distributions and Unices. It is as true on Ubuntu as on *BSD or Solaris... =20 Jerome

<quote> Unlike most GUI systems, command-line UNIX systems - with this program leading the charge - don't rely on filename extentions to tell you the type of a file, but look at the file's actual contents. </quote> They say "UNIX systems", they don't say "Ubuntu" (which I don't use anyway). Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Sep 16 2010
parent reply KennyTM~ <kennytm gmail.com> writes:
On Sep 17, 10 02:26, "Jérôme M. Berger" wrote:
 Jérôme M. Berger wrote:
 KennyTM~ wrote:
 On Sep 16, 10 04:35, "Jérôme M. Berger" wrote:
 Nick Sabalausky wrote:
 I didn't think unix file systems had a concept of mime type.

mime type and then choose the app associated to the mime type. Jerome


Which distro? I used the terms "Unix tools" because it transcends distributions and Unices. It is as true on Ubuntu as on *BSD or Solaris... Jerome

<quote> Unlike most GUI systems, command-line UNIX systems - with this program leading the charge - don't rely on filename extentions to tell you the type of a file, but look at the file's actual contents. </quote> They say "UNIX systems", they don't say "Ubuntu" (which I don't use anyway). Jerome

This describes the file(1) command, which the job is to inspect the file content and conclude what kind of file it actually is. But this is just one particular UNIX command. The command line interface in general does not care about the type of a regular file. This is needed in the GUI, but it is outside of the common parts of UNIX. There is no rule saying that a file manager must use file(1) or MIME type or extensions to determine the file type.
Sep 16 2010
next sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

KennyTM~ wrote:
 On Sep 17, 10 02:26, "J=C3=A9r=C3=B4me M. Berger" wrote:
 J=C3=A9r=C3=B4me M. Berger wrote:
 KennyTM~ wrote:
 On Sep 16, 10 04:35, "J=C3=A9r=C3=B4me M. Berger" wrote:
 Nick Sabalausky wrote:
 I didn't think unix file systems had a concept of mime type.






 mime type and then choose the app associated to the mime type.

          Jerome


Which distro? I used the terms "Unix tools" because it transcends=



 distributions and Unices. It is as true on Ubuntu as on *BSD or
 Solaris...

         Jerome

<quote> Unlike most GUI systems, command-line UNIX systems - with this program leading the charge - don't rely on filename extentions to tell you the type of a file, but look at the file's actual contents. </quote> They say "UNIX systems", they don't say "Ubuntu" (which I don't us=


 anyway).

         Jerome

This describes the file(1) command, which the job is to inspect the fil=

 content and conclude what kind of file it actually is.
=20

from the "file" web site, it states clearly that other apps look at the file contents instead of the extension. Of course, some apps don't care about the file type but some do. And most of those that do care don't use the extension.
 But this is just one particular UNIX command. The command line interfac=

 in general does not care about the type of a regular file. This is
 needed in the GUI, but it is outside of the common parts of UNIX. There=

 is no rule saying that a file manager must use file(1) or MIME type or
 extensions to determine the file type.
=20

manager must use the extension. However, on Windows, all the file managers I've tried have used the extension (actually, most of the time they don't use the extension themselves, they simply ask Windows to open the file and Windows uses the extension), whereas on UNIX most file managers use the file contents (usually, they don't use the file command, but instead rely on libmagic directly) and most applications will ignore the extension when asked to open a file (OK, some Windows applications do that too but on *NIX most of them do). Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Sep 17 2010
parent reply KennyTM~ <kennytm gmail.com> writes:
On Sep 18, 10 04:24, "Jérôme M. Berger" wrote:
 KennyTM~ wrote:
 On Sep 17, 10 02:26, "Jérôme M. Berger" wrote:


 This describes the file(1) command, which the job is to inspect the file
 content and conclude what kind of file it actually is.

from the "file" web site, it states clearly that other apps look at the file contents instead of the extension. Of course, some apps don't care about the file type but some do. And most of those that do care don't use the extension.

Many apps in Windows doesn't care about the file extension too. You can rename a bitmap to 'file.txt' and still can open it in MS Paint. This is irrelevant to UNIX.
 But this is just one particular UNIX command. The command line interface
 in general does not care about the type of a regular file. This is
 needed in the GUI, but it is outside of the common parts of UNIX. There
 is no rule saying that a file manager must use file(1) or MIME type or
 extensions to determine the file type.

manager must use the extension. However, on Windows, all the file managers I've tried have used the extension (actually, most of the time they don't use the extension themselves, they simply ask Windows to open the file and Windows uses the extension), whereas on UNIX most file managers use the file contents (usually, they don't use the file command, but instead rely on libmagic directly) and most applications will ignore the extension when asked to open a file (OK, some Windows applications do that too but on *NIX most of them do). Jerome

Mac OS X is UNIX. Finder cares about the file extension (besides metadata).
Sep 18 2010
parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

KennyTM~ wrote:
     True, but then, there is no rule that says that on windows a file
 manager must use the extension. However, on Windows, all the file
 managers I've tried have used the extension (actually, most of the
 time they don't use the extension themselves, they simply ask
 Windows to open the file and Windows uses the extension), whereas on
 UNIX most file managers use the file contents (usually, they don't
 use the file command, but instead rely on libmagic directly) and
 most applications will ignore the extension when asked to open a
 file (OK, some Windows applications do that too but on *NIX most of
 them do).

         Jerome

Mac OS X is UNIX. Finder cares about the file extension (besides metada=

most: You can use *most* to refer to the majority of a group of things or people or the largest part of something. One counter example does not invalidate my point. Especially when the example is invalid: MacOS X is *not* UNIX. True, the low level parts are UNIX-based, which makes it easy to port UNIX apps, however that doesn't make the whole into a UNIX. In particular, finder was ported from older versions of MacOS and inherits a large part of its behaviour from those older versions. Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Sep 20 2010
parent reply KennyTM~ <kennytm gmail.com> writes:
On Sep 21, 10 00:04, "Jérôme M. Berger" wrote:
 KennyTM~ wrote:
      True, but then, there is no rule that says that on windows a file
 manager must use the extension. However, on Windows, all the file
 managers I've tried have used the extension (actually, most of the
 time they don't use the extension themselves, they simply ask
 Windows to open the file and Windows uses the extension), whereas on
 UNIX most file managers use the file contents (usually, they don't
 use the file command, but instead rely on libmagic directly) and
 most applications will ignore the extension when asked to open a
 file (OK, some Windows applications do that too but on *NIX most of
 them do).

          Jerome

Mac OS X is UNIX. Finder cares about the file extension (besides metadata).

most: You can use *most* to refer to the majority of a group of things or people or the largest part of something. One counter example does not invalidate my point. Especially when the example is invalid: MacOS X is *not* UNIX. True, the low level parts are UNIX-based, which makes it easy to port UNIX apps, however that doesn't make the whole into a UNIX. In particular, finder was ported from older versions of MacOS and inherits a large part of its behaviour from those older versions. Jerome

Your definition of Unix is wrong then. Unix *only* specifies the API (system interface and headers) and the command-line utilities. You *are* confusing Unix and the distro. Ref: http://www.opengroup.org/onlinepubs/9699919799/
Sep 20 2010
next sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

KennyTM~ wrote:
 Your definition of Unix is wrong then. Unix *only* specifies the API
 (system interface and headers) and the command-line utilities. You *are=

 confusing Unix and the distro.
=20
 Ref: http://www.opengroup.org/onlinepubs/9699919799/

That's not UNIX, that's POSIX! And by that definition, Windows would be UNIX too... Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Sep 20 2010
next sibling parent KennyTM~ <kennytm gmail.com> writes:
On Sep 21, 10 01:43, "Jérôme M. Berger" wrote:
 KennyTM~ wrote:
 Your definition of Unix is wrong then. Unix *only* specifies the API
 (system interface and headers) and the command-line utilities. You *are*
 confusing Unix and the distro.

 Ref: http://www.opengroup.org/onlinepubs/9699919799/

That's not UNIX, that's POSIX! And by that definition, Windows would be UNIX too... Jerome

Looks like we have no point keep discussing on this since we have different view on what Unix means. My points are just: - in the CLI the type of regular file is usually irrelevant. - Unix (i.e. POSIX) doesn't specify how should the desktop component of the operating system determine the type of a regular file. Free desktop environments (e.g. Gnome, KDE, XFCE) stores the file type as MIME type.
Sep 20 2010
prev sibling parent Michel Fortin <michel.fortin michelf.com> writes:
On 2010-09-20 13:59:35 -0400, Jonathan M Davis <jmdavisProg gmx.com> said:

 Most of the stuff which cares about file extensions or mime types is going
 to be GUI-related and that has pretty much nothing to do with either 
 unix or posi
 x. However, it is typical for Linux systems (and I assume BSD systems) 
 to use the
 mime type primarily rather than the file extension. I had thought that Mac OS X
 was the same in that regard, but I guess not. I don't know though, since I
 don't use it.

Mac OS X applications mostly use UTIs. For files, the Uniform Type Identifier is determined by the file extension primarily, but can also be affected the executable bit being present and as a fallback by the older OSType metadata legacy from classic Mac OS. The UTI itself isn't stored with the file, it is determined on demand. UTIs are also used to represent various data types in other parts of the system, notably for copy-paste and drag and drop, and files received from the Internet where the MIME type is mapped to a UTI. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Sep 20 2010
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday, September 20, 2010 10:43:36 J=E9r=F4me M. Berger wrote:
 KennyTM~ wrote:
 Your definition of Unix is wrong then. Unix *only* specifies the API
 (system interface and headers) and the command-line utilities. You *are*
 confusing Unix and the distro.
=20
 Ref: http://www.opengroup.org/onlinepubs/9699919799/

That's not UNIX, that's POSIX! And by that definition, Windows would be UNIX too... =20 Jerome

Actually, technically, for an OS to be unix, it not only has to follow the= =20 appropriate specification, but someone has to foot the bill for it be certi= fied.=20 So, most OSes which are essentially unix aren't technically unix - Linux be= ing a=20 prime example. Personally, I think that it's a bit silly, but that's the wa= y it=20 is (since Unix is trademarked). Posix is a separate - albeit related - spe= c. Most of the stuff which cares about file extensions or mime types is going = to be=20 GUI-related and that has pretty much nothing to do with either unix or posi= x.=20 However, it is typical for Linux systems (and I assume BSD systems) to use = the=20 mime type primarily rather than the file extension. I had thought that Mac = OS X=20 was the same in that regard, but I guess not. I don't know though, since I = don't=20 use it. =2D Jonathan M Davis
Sep 20 2010
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Friday 17 September 2010 13:24:36 J=E9r=F4me M. Berger wrote:
 KennyTM~ wrote:
 On Sep 17, 10 02:26, "J=E9r=F4me M. Berger" wrote:
 J=E9r=F4me M. Berger wrote:
 KennyTM~ wrote:
 On Sep 16, 10 04:35, "J=E9r=F4me M. Berger" wrote:
 Nick Sabalausky wrote:
 I didn't think unix file systems had a concept of mime type.
=20

the =20 mime type and then choose the app associated to the mime type. =20 Jerome

Please don't confuse Unix with a distro. =20

=20 distributions and Unices. It is as true on Ubuntu as on *BSD or Solaris... =20 Jerome

BTW: http://www.darwinsys.com/file/ <quote> Unlike most GUI systems, command-line UNIX systems - with this program leading the charge - don't rely on filename extentions to tell you the type of a file, but look at the file's actual contents. </quote> =20 They say "UNIX systems", they don't say "Ubuntu" (which I don't use =20 anyway). =20 Jerome

This describes the file(1) command, which the job is to inspect the file content and conclude what kind of file it actually is.

I suggest you re-read the paragraph I posted. Although it was taken from the "file" web site, it states clearly that other apps look at the file contents instead of the extension. Of course, some apps don't care about the file type but some do. And most of those that do care don't use the extension. =20
 But this is just one particular UNIX command. The command line interface
 in general does not care about the type of a regular file. This is
 needed in the GUI, but it is outside of the common parts of UNIX. There
 is no rule saying that a file manager must use file(1) or MIME type or
 extensions to determine the file type.

True, but then, there is no rule that says that on windows a file manager must use the extension. However, on Windows, all the file managers I've tried have used the extension (actually, most of the time they don't use the extension themselves, they simply ask Windows to open the file and Windows uses the extension), whereas on UNIX most file managers use the file contents (usually, they don't use the file command, but instead rely on libmagic directly) and most applications will ignore the extension when asked to open a file (OK, some Windows applications do that too but on *NIX most of them do). =20 Jerome

It's so ingrained in Unix that extension isn't what matters that it totall= y=20 threw me of at one point when I couldn't get my flac files to play in audac= ious.=20 The file browser clearly indicated that they were flac files, but audacious= =20 wouldn't put them in its playlist. It turns out that audacious _does_ use t= he=20 extension, and I had screwed up with the settings on my CD ripper such that= =20 there was no extension on the files, so audacious didn't think that it coul= d read=20 them. That's the only time that I've ever seen that sort of problem in Linu= x.=20 Pretty much everything uses mime type. =2D Jonathan M Davis
Sep 17 2010
prev sibling next sibling parent Lutger <lutger.blijdestijn gmail.com> writes:
Nick Sabalausky wrote:

 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message
 news:mailman.227.1284590189.858.digitalmars-d puremagic.com...
 On Wednesday, September 15, 2010 12:48:32 Nick Sabalausky wrote:
 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...

 If you're on a non-Windows system, the mime-type becomes far more
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well)
 don't care
 about the extension. They just look at the mime type. Extensions become
 almost
 entirely a thing for the user. So, whether your file is useable becomes
 more of
 an issue of known mime type than known extension. Still, you don't
 generally
 want to just be making up extensions.

I didn't think unix file systems had a concept of mime type.

They don't have a concept of file extension either. Mime types has to do with the contents of the file and file extensions has to do with the name of the file. It's programs which interpret those, not the file system. Typically, on Windows, the extension is used by the OS to determine which program to use to open a file. In unix, it's the mime type that's used to determine that. The one bit of overlap there is the fact that Windows treats the exe extension essentially the way that unix treats the executable file attribute. Now, I wouldn't advise ditching file extensions in unix, since it not only can help the human using them but there are occasionally programs which check the extension rather the mime type (so, ultimately, you may end up using both the extension and the mime type), but it's primarily the mime type which is used, and it's definitely the mime type which is used to determine which program to use to open a file in the desktop environments.

Yea, but my question was more "how in the hell would it know the mime type of a file in the first place?" It's obviously not stored in the filename, and 99.9% is the time it's not stored in the file's data either. Since then, someone mentioned it typically analyses the content of the file and infers the mime type based on that. That's news to me. It would seem limited and error-prone though, so I have a hard time believing it doesn't suppliment that content-analysis with extension-checking in many cases.

Such a combination is sometimes used. Dolphin for example gives precedence to some extensions. But you'd be surprised how good content analysis alone works, for 99% of files I open from the desktop there is no extension required - it just works. Mostly you have either plain text or a well defined binary format.
Sep 16 2010
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2010-09-15 21:48, Nick Sabalausky wrote:
 "Jonathan M Davis"<jmdavisProg gmx.com>  wrote in message
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...
 If you're on a non-Windows system, the mime-type becomes far more
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well)
 don't care
 about the extension. They just look at the mime type. Extensions become
 almost
 entirely a thing for the user. So, whether your file is useable becomes
 more of
 an issue of known mime type than known extension. Still, you don't
 generally
 want to just be making up extensions.

I didn't think unix file systems had a concept of mime type.

I'm pretty sure HFS+ (Mac OS X) has some type of metadata in the file system. -- /Jacob Carlborg
Sep 16 2010
prev sibling parent "Nick Sabalausky" <a a.a> writes:
"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message 
news:op.vi4kyub1eav7ka localhost.localdomain...
 On Thu, 16 Sep 2010 01:16:20 -0400, Nick Sabalausky <a a.a> wrote:
 Yea, but my question was more "how in the hell would it know the mime 
 type
 of a file in the first place?" It's obviously not stored in the filename,
 and 99.9% is the time it's not stored in the file's data either.

Most binary file formats are designed to be detectable using a "magic number" that's found at the front of the file. This magic number allows programs to easily determine the file type. So yeah, it is stored in the file's data :)

Yea, I know, but I was thinking more about text formats (and the rare binary formats that don't have that). A lot of text-based formats out there don't use shebang syntax. And a lot of them are just small variations on each other (at least from a type-detection standpoint).
 Since then, someone mentioned it typically analyses the content of the 
 file
 and infers the mime type based on that. That's news to me. It would seem
 limited and error-prone though, so I have a hard time believing it 
 doesn't
 suppliment that content-analysis with extension-checking in many cases.

I think it's a combination of many things. Try the Linux 'file' command to see how it detects all different types of files.

Yea, that makes sence. Never knew that before though, I just assumed it was just extensions and shebang syntax.
Sep 16 2010
prev sibling next sibling parent retard <re tard.com.invalid> writes:
Wed, 15 Sep 2010 15:48:32 -0400, Nick Sabalausky wrote:

 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...
 If you're on a non-Windows system, the mime-type becomes far more
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well)
 don't care
 about the extension. They just look at the mime type. Extensions become
 almost
 entirely a thing for the user. So, whether your file is useable becomes
 more of
 an issue of known mime type than known extension. Still, you don't
 generally
 want to just be making up extensions.


Yep, they don't. The new file systems like reiserfs have support for arbitrary metadata fields, IIRC. But for example the standard Linux distributions have their mime/extension associations in /etc/mime.types
Sep 15 2010
prev sibling next sibling parent retard <re tard.com.invalid> writes:
Wed, 15 Sep 2010 22:35:27 +0200, Jérôme M. Berger wrote:

 Nick Sabalausky wrote:
 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...
 If you're on a non-Windows system, the mime-type becomes far more
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well)
 don't care
 about the extension. They just look at the mime type. Extensions
 become almost
 entirely a thing for the user. So, whether your file is useable
 becomes more of
 an issue of known mime type than known extension. Still, you don't
 generally
 want to just be making up extensions.


mime type and then choose the app associated to the mime type.

Unix tools?
Sep 15 2010
prev sibling parent retard <re tard.com.invalid> writes:
Tue, 21 Sep 2010 02:40:18 +0800, KennyTM~ wrote:

 On Sep 21, 10 01:43, "Jérôme M. Berger" wrote:
 KennyTM~ wrote:
 Your definition of Unix is wrong then. Unix *only* specifies the API
 (system interface and headers) and the command-line utilities. You
 *are* confusing Unix and the distro.

 Ref: http://www.opengroup.org/onlinepubs/9699919799/

That's not UNIX, that's POSIX! And by that definition, Windows would be UNIX too... Jerome

Looks like we have no point keep discussing on this since we have different view on what Unix means. My points are just: - in the CLI the type of regular file is usually irrelevant. - Unix (i.e. POSIX) doesn't specify how should the desktop component of the operating system determine the type of a regular file. Free desktop environments (e.g. Gnome, KDE, XFCE) stores the file type as MIME type.

The post by Jonathan M Davis ( http://www.digitalmars.com/webnews/ newsgroups.php?art_group=digitalmars.D&article_id=117660 ) was the most informative post in this thread. You should both study that carefully.
Sep 20 2010
prev sibling next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Wednesday, September 15, 2010 12:48:32 Nick Sabalausky wrote:
 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...
 
 If you're on a non-Windows system, the mime-type becomes far more
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well)
 don't care
 about the extension. They just look at the mime type. Extensions become
 almost
 entirely a thing for the user. So, whether your file is useable becomes
 more of
 an issue of known mime type than known extension. Still, you don't
 generally
 want to just be making up extensions.

I didn't think unix file systems had a concept of mime type.

They don't have a concept of file extension either. Mime types has to do with the contents of the file and file extensions has to do with the name of the file. It's programs which interpret those, not the file system. Typically, on Windows, the extension is used by the OS to determine which program to use to open a file. In unix, it's the mime type that's used to determine that. The one bit of overlap there is the fact that Windows treats the exe extension essentially the way that unix treats the executable file attribute. Now, I wouldn't advise ditching file extensions in unix, since it not only can help the human using them but there are occasionally programs which check the extension rather the mime type (so, ultimately, you may end up using both the extension and the mime type), but it's primarily the mime type which is used, and it's definitely the mime type which is used to determine which program to use to open a file in the desktop environments. - Jonathan M Davis
Sep 15 2010
parent "Nick Sabalausky" <a a.a> writes:
"Jonathan M Davis" <jmdavisProg gmx.com> wrote in message 
news:mailman.227.1284590189.858.digitalmars-d puremagic.com...
 On Wednesday, September 15, 2010 12:48:32 Nick Sabalausky wrote:
 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...

 If you're on a non-Windows system, the mime-type becomes far more
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well)
 don't care
 about the extension. They just look at the mime type. Extensions become
 almost
 entirely a thing for the user. So, whether your file is useable becomes
 more of
 an issue of known mime type than known extension. Still, you don't
 generally
 want to just be making up extensions.

I didn't think unix file systems had a concept of mime type.

They don't have a concept of file extension either. Mime types has to do with the contents of the file and file extensions has to do with the name of the file. It's programs which interpret those, not the file system. Typically, on Windows, the extension is used by the OS to determine which program to use to open a file. In unix, it's the mime type that's used to determine that. The one bit of overlap there is the fact that Windows treats the exe extension essentially the way that unix treats the executable file attribute. Now, I wouldn't advise ditching file extensions in unix, since it not only can help the human using them but there are occasionally programs which check the extension rather the mime type (so, ultimately, you may end up using both the extension and the mime type), but it's primarily the mime type which is used, and it's definitely the mime type which is used to determine which program to use to open a file in the desktop environments.

Yea, but my question was more "how in the hell would it know the mime type of a file in the first place?" It's obviously not stored in the filename, and 99.9% is the time it's not stored in the file's data either. Since then, someone mentioned it typically analyses the content of the file and infers the mime type based on that. That's news to me. It would seem limited and error-prone though, so I have a hard time believing it doesn't suppliment that content-analysis with extension-checking in many cases.
Sep 15 2010
prev sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Thu, 16 Sep 2010 01:16:20 -0400, Nick Sabalausky <a a.a> wrote:

 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message
 news:mailman.227.1284590189.858.digitalmars-d puremagic.com...
 On Wednesday, September 15, 2010 12:48:32 Nick Sabalausky wrote:
 "Jonathan M Davis" <jmdavisProg gmx.com> wrote in message
 news:mailman.225.1284568096.858.digitalmars-d puremagic.com...

 If you're on a non-Windows system, the mime-type becomes far more
 important than
 the extension. Most programs in Linux (and I believe MacOS X as well)
 don't care
 about the extension. They just look at the mime type. Extensions  

 almost
 entirely a thing for the user. So, whether your file is useable  

 more of
 an issue of known mime type than known extension. Still, you don't
 generally
 want to just be making up extensions.

I didn't think unix file systems had a concept of mime type.

They don't have a concept of file extension either. Mime types has to do with the contents of the file and file extensions has to do with the name of the file. It's programs which interpret those, not the file system. Typically, on Windows, the extension is used by the OS to determine which program to use to open a file. In unix, it's the mime type that's used to determine that. The one bit of overlap there is the fact that Windows treats the exe extension essentially the way that unix treats the executable file attribute. Now, I wouldn't advise ditching file extensions in unix, since it not only can help the human using them but there are occasionally programs which check the extension rather the mime type (so, ultimately, you may end up using both the extension and the mime type), but it's primarily the mime type which is used, and it's definitely the mime type which is used to determine which program to use to open a file in the desktop environments.

Yea, but my question was more "how in the hell would it know the mime type of a file in the first place?" It's obviously not stored in the filename, and 99.9% is the time it's not stored in the file's data either.

Most binary file formats are designed to be detectable using a "magic number" that's found at the front of the file. This magic number allows programs to easily determine the file type. So yeah, it is stored in the file's data :)
 Since then, someone mentioned it typically analyses the content of the  
 file
 and infers the mime type based on that. That's news to me. It would seem
 limited and error-prone though, so I have a hard time believing it  
 doesn't
 suppliment that content-analysis with extension-checking in many cases.

I think it's a combination of many things. Try the Linux 'file' command to see how it detects all different types of files. -Steve
Sep 16 2010