globbing source for C

Discussion in 'C Programming' started by Owner, May 12, 2011.

  1. Owner

    Owner Guest

    I'm looking for source of globbing. because win 7 does not
    change * to file names in commmandline.

    So, looks like I have build one.

    can anyone give me help by pointing at somewhere start with?
     
    Owner, May 12, 2011
    #1
    1. Advertising

  2. Owner <> writes:
    > I'm looking for source of globbing. because win 7 does not
    > change * to file names in commmandline.
    >
    > So, looks like I have build one.
    >
    > can anyone give me help by pointing at somewhere start with?


    A quick Google search finds a Windows-specific solution (which is
    probably ok because it's Windows that has the problem):

    http://stackoverflow.com/questions/1269480/globbing-in-c-c-on-windows

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, May 12, 2011
    #2
    1. Advertising

  3. Owner

    Owner Guest

    Thank you.
     
    Owner, May 12, 2011
    #3
  4. "Owner" <> schrieb im Newsbeitrag
    news:p...
    > I'm looking for source of globbing. because win 7 does not
    > change * to file names in commmandline.
    >
    > So, looks like I have build one.
    >
    > can anyone give me help by pointing at somewhere start with?


    On Windows you might look for findfirst(), findnext(), findclose().
    On Linux you might look for opendir()
     
    Heinrich Wolf, May 12, 2011
    #4
  5. Owner

    Shao Miller Guest

    On 5/11/2011 20:53, Owner wrote:
    > I'm looking for source of globbing. because win 7 does not
    > change * to file names in commmandline.
    >
    > So, looks like I have build one.
    >
    > can anyone give me help by pointing at somewhere start with?


    With apologies for being off-topic for C, here's some batch that might
    help, too:

    @echo off
    goto :_main

    :: Create an environment variable with a list of files
    :: that match a globbing pattern.
    ::
    :: Parameters:
    :: 1 : The globbing pattern to be expanded
    :: Returns:
    :: _glob : This variable is set with the list of files

    :_glob
    set _glob=
    for /f %%a in ('dir /a /b "%~1"') do (
    call :_build_glob "%%a"
    )
    goto :eof

    :_build_glob
    if "%_glob%"=="" (
    set _glob=%1
    ) else (
    set _glob=%_glob% %1
    )
    goto :eof


    :_main
    echo.
    echo Testing pattern *.bat...
    echo.
    call :_glob *.bat
    echo _glob=%_glob%
    echo.
    echo Testing pattern *.t?t...
    echo.
    call :_glob *.t?t
    echo _glob=%_glob%
     
    Shao Miller, May 12, 2011
    #5
  6. "Heinrich Wolf" <> writes:
    > "Owner" <> schrieb im Newsbeitrag
    > news:p...
    >> I'm looking for source of globbing. because win 7 does not
    >> change * to file names in commmandline.
    >>
    >> So, looks like I have build one.
    >>
    >> can anyone give me help by pointing at somewhere start with?

    >
    > On Windows you might look for findfirst(), findnext(), findclose().
    > On Linux you might look for opendir()


    <OT>

    On Linux, you probably don't need to do you own globbing, and you
    shouldn't try. If I invoke a program with the command line

    ./program *.txt

    the program will see a list of all the matching files; it will have no
    way of knowing they were expanded from a wildcard. And if one of those
    file names happens to have a '*' in it (which is perfectly legal), you
    don't want to try to re-expand it.

    </OT>

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, May 12, 2011
    #6
  7. Owner

    James Kuyper Guest

    On 05/12/2011 09:07 AM, Datesfat Chicks wrote:
    ....
    > c)It is my understanding that the treatment of command-line arguments
    > has always been different in Windows (i.e. it predates Windows 7 by
    > far). *nix globs for you, Windows does not.


    It's not the operating system that does those things, it's the shell
    (tcsh, on my machine), or the command line interpreter (CLI)
    (command.com, on my wife's machine). Use an unconventional shell or CLI
    and the behavior could be quite different, on both operating systems.
    --
    James Kuyper
     
    James Kuyper, May 13, 2011
    #7
  8. Owner wrote:
    >I'm looking for source of globbing. because win 7 does not
    >change * to file names in commmandline.


    You can find working examples in the source code of the various shells
    provided by the Cygwin project.
    --
    Roberto Waltman

    [ Please reply to the group.
    Return address is invalid ]
     
    Roberto Waltman, May 16, 2011
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Philips

    Case-insensitive globbing

    Thomas Philips, Jun 3, 2004, in forum: Python
    Replies:
    4
    Views:
    587
    Derek Chen-Becker
    Jun 3, 2004
  2. Replies:
    5
    Views:
    419
  3. Replies:
    3
    Views:
    294
  4. Daz
    Replies:
    3
    Views:
    342
  5. Joel C. Salomon

    Re: globbing source for C

    Joel C. Salomon, May 12, 2011, in forum: C Programming
    Replies:
    4
    Views:
    620
    Ben Bacarisse
    May 14, 2011
Loading...

Share This Page