Thread: Files and wildcards

  1. #1
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466

    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.

  3. #3
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466

    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.

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, 08: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, 02:40 PM