Results 1 to 3 of 3
I'm making a program and I need to know what if a file is a wav without using it's extension (as it can be random in my instance). In the ...
- 09-14-2007 #1Just Joined!
- Join Date
- Sep 2007
- Posts
- 1
C :: Detecting file type
I'm making a program and I need to know what if a file is a wav without using it's extension (as it can be random in my instance). In the file's properties, it says something like Mime: wav/audio. I want to get that info for my program. Any clues on where to start?
- 09-14-2007 #2
These things are usually determined by something called the magic number: a unique identifier in the first few bytes of the file. You can check the file man page for some info on how it identifies files. Maybe play around with it and see how you can use it.
DISTRO=Arch
Registered Linux User #388732
- 09-17-2007 #3Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
you could use "od" to look for the magic number:
take several .wav files 1.wav, 2.wav, 3.wav say:
od 1.wav
od 2.wav
od.3.wav
see whether the first few bytes have a magic number;
if so, then in your program, after you open the file,
you can look for the magic number.the sun is new every day (heraclitus)


Reply With Quote