On Friday, 4 October 2013 at 08:27:00 UTC, FreeSlave wrote:
On Friday, 4 October 2013 at 08:06:24 UTC, simendsjo wrote:
On Friday, 4 October 2013 at 07:39:36 UTC, FreeSlave wrote:
I was suggested to bring this idea up here.
fileType should be a function for determining of file type.
Example of usage:
Suppose application uses special directory for plugins (i.e.
dynamic libraries). In graphics user interface it can be
reflected like list of checkboxes that show which plugins are
on and which are off. To implement this we should know that
file actually represents dynamic library without trying to
load it into executable memory. Yes, we can load and unload
every file in place to check that it's valid dynamic library
but it's some kind of hack.
Another example is file manager. It has icons for the most
common file types and usually relies on file extension to
determine which icon should be used. But we can't always rely
on extension. For example many games use .pk3 extension as
alias to .zip, but file manager know nothing about it and
shows these files like ones with unknown extension.
So how do you think does phobos need these capabilities? May
be you have other examples where this function can be useful.
Seems a bit specific to be put in the standard library. If you
don't mind GPL, you can look at the source for file:
http://www.darwinsys.com/file/
Ok, I'll check it out.
I've just called to mind another use, the most important I
think. It's for web services to prevent from uploading possibly
harmful files (executables) or to check service support for
given file.
The executable thing is quite simple:
For windows, check for ".exe" or ".com", for *nix, check for
executable flag.
Browsers already complain about these though, so people
distributing malware probably does other things like putting them
in compressed files. In that case, your file tool would have to
open every .zip, .rar, .7z, .gz etc etc and check every file
within recursively.
A bit OT regarding filetypes in the std lib though :)