[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

globbing source for C

Owner

5/12/2011 12:53:00 AM

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?
9 Answers

Keith Thompson

5/12/2011 1:33:00 AM

0

Owner <Owner@Owner-PC.com> 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-...

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.ne...
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Owner

5/12/2011 2:03:00 AM

0

Thank you.

Dave \Crash\ Dummy

5/12/2011 12:40:00 PM

0


"Owner" <Owner@Owner-PC.com> schrieb im Newsbeitrag
news:pan.2011.05.12.00.53.00.855000@Owner-PC.com...
> 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()

Datesfat Chicks

5/12/2011 1:08:00 PM

0

I'm glad that other posters were able to provide some guidance.

Here are other suggestions and thoughts that come to mind:

a)There is a newsgroup devoted to Win32 programming. I don't remember
the exact name (and I'm too lazy to look it up), but it is something
like "comp.os.mswindows.programmer.win32". I've found that the folks
there are very helpful.

b)The entire Windows API is online at www.microsoft.com. Again, I'm
too lazy to look up exactly where. Microsoft does have the API
documented, but sometimes finding which function is as hard as knowing
what the function does.

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.

d)If you do any serious programming, I understand that Charles
Petzold's book is the standard. But the folks at (a) could probably
give you other great book recommendations.

I hope that (a) is helpful.

DFC

Shao Miller

5/12/2011 1:32:00 PM

0

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%

Keith Thompson

5/12/2011 3:08:00 PM

0

"Heinrich Wolf" <invalid@invalid.invalid> writes:
> "Owner" <Owner@Owner-PC.com> schrieb im Newsbeitrag
> news:pan.2011.05.12.00.53.00.855000@Owner-PC.com...
>> 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) kst-u@mib.org <http://www.ghoti.ne...
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Kenneth Brody

5/12/2011 5:38:00 PM

0

On 5/11/2011 8:53 PM, 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 Microsoft Visual C, include "/link setargv.obj" on the command line
when you build the program, and the runtime library startup code will do
command-line wildcard expansion for you.

For more information, you'll need to ask in one of the Microsoft-specific
newsgroups.

--
Kenneth Brody

James Kuyper

5/13/2011 12:33:00 AM

0

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

Roberto Waltman

5/16/2011 3:15:00 AM

0

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 ]