Files and wildcards

This is a discussion on Files and wildcards within the C Programming forums, part of the General Programming Boards category; I want to make a encryption program that will accept directories and wildcards on the command line, such as: encrypt ...

  1. #1
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Posts
    306

    Files and wildcards

    I want to make a encryption program that will accept directories and wildcards on the command line, such as: encrypt /home/* or encrypt /home/???.jpg. If this is platform specific, I'm using linux. What headers and functions can I use to locate a match? Algorithm would be something like: move to directory specified, get first filename, if it's a match call encrypt function, get next filename, repeat.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    In Linux, wildcard expansion is usually performed by the shell (unless you've set the noglob option).
    All your program sees is a rather large value of argc and a corresponding number of argv strings.
    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.

  3. #3
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Posts
    306

    Thanks

    Well, that's good news. Very good news. Wonder if my code will be portable to Windows, though. Guess the only way is to write it and try it out. Thanks for the response.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    Modern compilers which expect cmd.exe to be the shell will probably expand wildcards (or can be made to at least).

    Fossils on the other hand which only know about command.com (with it's 120+ char limit on total command line length) usually defaulted to no expansion IIRC (but could be made to).
    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. Trying to get my App to copy files with wildcards
    By Dwizard in forum Windows Programming
    Replies: 3
    Last Post: 09-30-2005, 05:49 PM
  2. extracting files from a rar/zip
    By jverkoey in forum Windows Programming
    Replies: 2
    Last Post: 03-28-2003, 07:55 AM
  3. I want to investigate my machine.
    By mary in forum C Programming
    Replies: 8
    Last Post: 06-05-2002, 11:23 AM
  4. getting filenames
    By madsmile in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2002, 01:40 PM

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