V
Vipin
I need the globing support on Windows for one of my application
written in C / c++ language.
Can any body point me to the help in that regards.
Following code works well on UNIX but there is no <glob.h> or
equivalent on windows in my opinion.
Please share the code if anybody has written already.
#include <stdio.h>
#include <glob.h>
int glob_err_handler(const char *path,int errno){
switch(errno){
case GLOB_ABORTED:
printf("\nPermission denied on path %s",path);
break;
case GLOB_NOMATCH:
printf("\nNo matching source files found.");
break;
case GLOB_NOSPACE:
printf("\nOut of memory while trying to read matching source
files.");
break;
default:
printf("\n Unknown Error.");
}
return 0;
}
int main (int argc, char *argv[]){
glob_t t;
int retval;
int flags;
flags = 1;/* As per standards, do not use GLOB_APPEND on first call.*/
retval = glob("./xs*/*.v",flags,glob_err_handler,&t);
flags |=GLOB_APPEND;
retval = glob("./*/*.v",flags,glob_err_handler,&t);
printf("\n Printing the matching paths ... - %d ",retval);
for(flags=0;flags < t.gl_pathc;flags++){
printf("\n%s",t.gl_pathv[flags]);
}
globfree(&t);
printf("\n\n");
return 0;
}
written in C / c++ language.
Can any body point me to the help in that regards.
Following code works well on UNIX but there is no <glob.h> or
equivalent on windows in my opinion.
Please share the code if anybody has written already.
#include <stdio.h>
#include <glob.h>
int glob_err_handler(const char *path,int errno){
switch(errno){
case GLOB_ABORTED:
printf("\nPermission denied on path %s",path);
break;
case GLOB_NOMATCH:
printf("\nNo matching source files found.");
break;
case GLOB_NOSPACE:
printf("\nOut of memory while trying to read matching source
files.");
break;
default:
printf("\n Unknown Error.");
}
return 0;
}
int main (int argc, char *argv[]){
glob_t t;
int retval;
int flags;
flags = 1;/* As per standards, do not use GLOB_APPEND on first call.*/
retval = glob("./xs*/*.v",flags,glob_err_handler,&t);
flags |=GLOB_APPEND;
retval = glob("./*/*.v",flags,glob_err_handler,&t);
printf("\n Printing the matching paths ... - %d ",retval);
for(flags=0;flags < t.gl_pathc;flags++){
printf("\n%s",t.gl_pathv[flags]);
}
globfree(&t);
printf("\n\n");
return 0;
}