LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-01-2003, 11:00 PM   #1
debdas
LQ Newbie
 
Registered: May 2003
Posts: 19

Rep: Reputation: 0
determining a binary file


How can I determine whether a file is a binary file or not using c programming. Especially when the file extensio is not available to us or a it is a file that has no extension.
 
Old 05-01-2003, 11:25 PM   #2
soothsayer
Member
 
Registered: Apr 2003
Location: Tampabay Area
Distribution: redhat 6.2-9
Posts: 33

Rep: Reputation: 15
type

file filename

and it will give a description of the file
 
Old 05-02-2003, 01:13 PM   #3
Nukes
Member
 
Registered: Apr 2003
Location: Scotland UK
Distribution: Gentoo
Posts: 92

Rep: Reputation: 15
if you want to write a C program for this, take a look at the manpages for file and magic and maybe at the source code for file. There isn't really an easy way of explaining it here, but each file has a 'magic number' that identifies its type. Look at the manpages and you should see what I mean. you could just call the code for file as a routine in your program.
 
Old 05-05-2003, 06:18 AM   #4
debdas
LQ Newbie
 
Registered: May 2003
Posts: 19

Original Poster
Rep: Reputation: 0
re:file

Is it a bad programming practice to execute the file shell command using the system() function. I have used that in my code right now...


Pls. advice
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
determining file types supersucker Linux - Newbie 2 05-03-2005 12:29 PM
Determining MIME Type of a File Jose Muņiz Linux - General 2 08-16-2004 01:44 AM
Determining Whether HTTP File Exists overbored Linux - Software 1 05-22-2004 01:30 AM
determining file system 24jedi Linux - General 2 07-31-2003 10:26 AM
Determining if a file is binary or text Cyth Linux - General 3 02-27-2003 12:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration