WindowsHelper.cpp

00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #include "WindowsHelper.h"
00019 #ifdef    __WIN32__
00020 #ifndef   __GNUC__
00021 #include <dir.h>
00022 
00023 void WildCardArguments(int & argc, char ** & argv)
00024 {
00025     if (argc < 2) return;
00026 
00027     int  count = 0;
00028     for (int i = 1; i < argc; i++)
00029     {
00030         struct ffblk blk;
00031 
00032         int done = findfirst(argv[i], &blk, 0);
00033         while (!done)
00034         {
00035             done = findnext(&blk);
00036             count++;
00037         }
00038     }
00039 
00040     char ** new_argv = new char * [count + 1];
00041     int     new_argc = 1;
00042 
00043     new_argv[0] = argv[0];
00044     for (int i = 1; i < argc; i++)
00045     {
00046         struct ffblk blk;
00047 
00048         int done = findfirst(argv[i], &blk, 0);
00049         while (!done && new_argc <= count)
00050         {
00051             new_argv[new_argc++] = strdup(blk.ff_name);
00052             done = findnext(&blk);
00053         }
00054     }
00055 
00056     argc = new_argc;
00057     argv = new_argv;
00058 }
00059 
00060 #endif
00061 #endif
00062 
Generated on Wed Nov 17 15:38:29 2010 for StatGen Software by  doxygen 1.6.3