#include <glib.h>
-#include <wiretap/file_util.h>
+#include <wsutil/file_util.h>
#include "globals.h"
#include <epan/filesystem.h>
fileset_filename_match_pattern(const char *fname)
{
char *pfx;
- int baselen;
- int minlen = strlen("_00001_20050418010750");
+ size_t baselen;
+ size_t minlen = strlen("_00001_20050418010750");
char *filename;
-
+
/* d:\dir1\test_00001_20050418010750.cap */
filename = g_strdup(get_basename(fname));
/* test_00001_20050418010750.cap */
pfx = strrchr(filename, '.');
- if(pfx == NULL) {
- return FALSE;
+ if(pfx == NULL) { /* suffix is optional */
+ pfx = filename + strlen(filename);
}
/* test_00001_20050418010750 */
*pfx = '\0';
while(minlen--) {
baselen--;
- if(!isdigit( (int) filename[baselen])) {
+ if(!isdigit( (guchar) filename[baselen])) {
g_free(filename);
return FALSE;
}
char *pfx2;
char *dup_f1;
char *dup_f2;
- int minlen = strlen("_00001_20050418010750");
+ size_t minlen = strlen("_00001_20050418010750");
/* just to be sure ... */
pfx1 = strrchr(dup_f1, '.');
pfx2 = strrchr(dup_f2, '.');
+ /* suffix is optional */
+ if (!pfx1) pfx1 = dup_f1 + strlen(dup_f1);
+ if (!pfx2) pfx2 = dup_f2 + strlen(dup_f2);
/* the optional suffix (file extension) must be equal */
if(strcmp(pfx1, pfx2) != 0) {
path = g_strdup_printf("%s%s", dirname, fname);
- fh = eth_open( path, O_RDONLY, 0000 /* no creation so don't matter */);
+ fh = ws_open( path, O_RDONLY, 0000 /* no creation so don't matter */);
if(fh != -1) {
/* Get statistics */
set.entries = g_list_append(set.entries, entry);
}
- eth_close(fh);
+ ws_close(fh);
}
g_free(path);
void
fileset_add_dir(const char *fname)
{
- ETH_DIR *dir; /* scanned directory */
- ETH_DIRENT *file; /* current file */
+ WS_DIR *dir; /* scanned directory */
+ WS_DIRENT *file; /* current file */
const char *name;
fileset_entry *entry;
GString *dirname;
dirname = g_string_new(fname_dup);
g_free(fname_dup);
- set.dirname = g_strdup(dirname->str);
-
+ set.dirname = g_strdup(dirname->str);
+
dirname = g_string_append_c(dirname, G_DIR_SEPARATOR);
/* is the current file probably a part of any fileset? */
if(fileset_filename_match_pattern(fname)) {
/* yes, go through the files in the directory and check if the file in question is part of the current file set */
- if ((dir = eth_dir_open(dirname->str, 0, NULL)) != NULL) {
- while ((file = eth_dir_read_name(dir)) != NULL) {
- name = eth_dir_get_name(file);
+ if ((dir = ws_dir_open(dirname->str, 0, NULL)) != NULL) {
+ while ((file = ws_dir_read_name(dir)) != NULL) {
+ name = ws_dir_get_name(file);
if(fileset_filename_match_pattern(name) && fileset_is_file_in_set(name, get_basename(fname))) {
fileset_add_file(dirname->str, name, strcmp(name, get_basename(fname))== 0 /* current */);
}
} /* while */
- eth_dir_close(dir);
+ ws_dir_close(dir);
} /* if */
} else {
/* no, this is a "standalone file", just add this one */