Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > globbing source for C

Reply
Thread Tools

globbing source for C

 
 
Owner
Guest
Posts: n/a
 
      05-12-2011
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?
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      05-12-2011
Owner <(E-Mail Removed)> 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/1...c-c-on-windows

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <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"
 
Reply With Quote
 
 
 
 
Owner
Guest
Posts: n/a
 
      05-12-2011
Thank you.
 
Reply With Quote
 
Heinrich Wolf
Guest
Posts: n/a
 
      05-12-2011

"Owner" <(E-Mail Removed)> schrieb im Newsbeitrag
news(E-Mail Removed)...
> 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()

 
Reply With Quote
 
Shao Miller
Guest
Posts: n/a
 
      05-12-2011
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%
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      05-12-2011
"Heinrich Wolf" <(E-Mail Removed)> writes:
> "Owner" <(E-Mail Removed)> schrieb im Newsbeitrag
> news(E-Mail Removed)...
>> 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) (E-Mail Removed) <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"
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      05-13-2011
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
 
Reply With Quote
 
Roberto Waltman
Guest
Posts: n/a
 
      05-16-2011
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 ]
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: globbing source for C Joel C. Salomon C Programming 4 05-14-2011 02:18 AM
Globbing files by their creation date tkpmep@hotmail.com Python 3 01-17-2007 04:31 PM
File Copying With Globbing Daz C++ 3 05-03-2006 11:08 AM
globbing multiple wildcards utabintarbo@gmail.com Python 5 05-07-2005 10:40 PM
Case-insensitive globbing Thomas Philips Python 4 06-03-2004 08:47 PM



Advertisments