Newsgroup: comp.lang.c++


Date: Sun, 30 Apr 2006 22:34:03 +0300
From: Diomidis Spinellis <dds@aueb.gr>
Organization: Athens University of Economics and Business
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060404 SeaMonkey/1.0.1
MIME-Version: 1.0
Newsgroups: comp.lang.c++
Subject: Re: File Copying With Globbing
References: <1146423657.269526.148720@i39g2000cwa.googlegroups.com>
In-Reply-To: <1146423657.269526.148720@i39g2000cwa.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Daz wrote:
> Hi everyone!
> 
> This is my first time posting in this group, although I have been
> watching it for the past few months and have to say this is possibly
> the best group I have seen on Google so far! (That wasn't a
> butt-kissing comment, I just believe in giving praise when it's due).
> 
> I would like to copy files using globbing, and I am not sure of the
> best way to do it. I have tried using system("COPY [source]
> [destination]"), but It's still not quite what I am looking for.
> 
> Firstly (as this is a console application), I see the message "1
> file(s) copied.", which I would rather not see. And...
> Secondly I need to know the name of the output file once the copying
> has completed.
> 
> I need to be able to copy files using both '*' and '?' wildcards, and I
> will need a method of finding out what the output file was. I can only
> think of long-winded ways of acheiving my objective, and if that's the
> route I need to take, then so be it, but it would be great if there is
> a function that I have overlooked so I don't need to find a big regex
> header file to use in my tiny program.
> 
> Copying the file is only the first phase of the operation, before the
> output file is formatted (hence why I need to know the name of the
> output file).
> 
> If there is no standard way of doing this, any suggestions would be
> fantastic. I have been learning C++ for about 3 months now, and I am
> self-taught (to give me a headstart when I go to college), so I am far
> from being an expert. With that said, I am not using it as an excuse
> for my ignorance as I believe the best way to learn it by 'doing'.
> However, I would rather learn to do something in the best way, as
> opposed to learning the best ways in which how NOT to do something, and
> never finding the best answer.
> 
> I don't necessarilly expect a solution, but any pointers (not *pointers
> :P) would be very much appreciated.

Filename globbing is either implemented at the level of the operating 
system command shell (this is for example the case in Unix-type 
systems), or by individual programs (this is for example the case on the 
Windows platform default shell cmd32).  In the first case your program 
will receive the already expanded arguments in argv[].  In the second 
case, you program could either perform the globbing by itsself (through 
platform-specific mechanisms, like opendir, readdir) or rely on an 
external library.  For example, on some versions of Microsoft's 
compilers you can have globbing performed internally before the 
command-line arguments are passed to main by linking your program with 
the supplied setargv.obj file.  As you can see, none of globbing options 
are related to the C++ language; all depend on platform-specific 
functionality.


-- 
Diomidis Spinellis
Code Quality: The Open Source Perspective (Addison-Wesley 2006)
http://www.spinellis.gr/codequality?clcpp



Newsgroup comp.lang.c++ contents
Newsgroup list
Diomidis Spinellis home page

Creative Commons License Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.