Commit 23caf521 authored by claes's avatar claes

get_files added

parent 9c47ed0a
/**
* Proview $Id: co_dcli.h,v 1.10 2007-01-04 07:51:42 claes Exp $
* Proview $Id: co_dcli.h,v 1.11 2008-04-25 11:26:04 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -102,6 +102,11 @@ int dcli_search_file( char *file_name ,
char *found_file,
int new_search);
int dcli_get_files( char *dir,
char *pattern,
pwr_tString40 *filelist[],
int *filecnt);
int dcli_parse_filename( char *filename,
char *dev,
char *dir,
......
/**
* Proview $Id: co_dcli_dir.c,v 1.4 2005-09-01 14:57:52 claes Exp $
* Proview $Id: co_dcli_dir.c,v 1.5 2008-04-25 11:26:04 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -272,6 +272,60 @@ int dcli_search_file( char *name ,
return DCLI__SUCCESS;
}
/*************************************************************************
*
* Name: dcli_get_files
*
*
**************************************************************************/
int dcli_get_files( char *dir, char *pattern, pwr_tString40 *filelist[], int *filecnt)
{
pwr_tStatus sts;
pwr_tFileName file_spec, found_file;
int cnt = 0;
int idx = 0;
char *s;
strcpy( file_spec, dir);
strcat( file_spec, "/");
strcat( file_spec, pattern);
dcli_translate_filename( file_spec, file_spec);
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT);
while ( ODD(sts)) {
cnt++;
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_NEXT);
}
dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END);
if ( !cnt) {
*filecnt = 0;
return 0;
}
*filelist = calloc( cnt, sizeof( pwr_tString40));
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT);
while ( ODD(sts)) {
if ( (s = strrchr( found_file, '/'))) {
strncpy( (*filelist)[idx], s+1, sizeof(pwr_tString40));
(*filelist)[idx][sizeof(pwr_tString40)-1] = 0;
}
else {
strncpy( (*filelist)[idx], found_file, sizeof(pwr_tString40));
(*filelist)[idx][sizeof(pwr_tString40)-1] = 0;
}
idx++;
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_NEXT);
}
dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END);
*filecnt = cnt;
return DCLI__SUCCESS;
}
/*************************************************************************
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment