Reputation: 573
Is there a C library function to get the extension of file? I know that I can design a function on my own to get extension after '.' but not all files are stored with their extensions when we read them.
Upvotes: 0
Views: 474
Reputation: 6335
The file
command in Linux uses a library called libmagic (don't confuse with libmagick) to check the 'magic' bytes in the file itself to determine the likely content type.
The library is fairly cross platform, it's well documented, for example here: http://linux.die.net/man/3/libmagic
Upvotes: 3
Reputation: 61
So you'd like to get the type of a file? Maybe the command 'file' in Linux is what you want. You can check its source code.
Upvotes: 4