Reputation: 171
I need to get file type without using file extensions on linux. There is "file" utility, which can do this. How can I do the same using C/C++? Not 'system(const char *)', of course... Thanks)
Upvotes: 1
Views: 819
Reputation: 1041
AFAIK file
is implemented over libmagic
. For more reference see:
file
sources Upvotes: 5
Reputation: 12009
Either call file
as a child process or emulate what it does. There are no other options if you want to intelligently examine a file's content to guess what it contains.
Upvotes: 1