determine file type

This is a discussion on determine file type within the Linux Programming forums, part of the Platform Specific Boards category; hi, in my previous post i said i have a char *filename and want to determine whether the file (given ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    16

    determine file type

    hi,

    in my previous post i said i have a char *filename and want to determine whether the file (given it exists) is executable (either a binary or a #! file)

    my solution is now to search the output of

    #file filename


    for the substring "executable". i wonder if this is generally a good idea? will localized versions of the "file" program output "executable" too, or anything in a different language?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    Yeah, answered already in the other thread.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. header file bringing errors?
    By bluehead in forum Windows Programming
    Replies: 4
    Last Post: 08-19-2003, 12:51 PM
  5. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21