Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
+ --exclude='WILDCARD[;WILDCARD]' - Exclude files & directories match…
Browse files Browse the repository at this point in the history
…ing a wildcard (case-insensitive)
  • Loading branch information
stsaz committed Jun 9, 2018
1 parent b75b260 commit a3a5405
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ INPUT:
--flist=FILE Read filenames from FILE
--include='WILDCARD[;WILDCARD]'
Only include files matching a wildcard (case-insensitive)
--exclude='WILDCARD[;WILDCARD]'
Exclude files & directories matching a wildcard (case-insensitive)
--seek=TIME Seek to time: [[HH:]MM:]SS[:MSC]
--until=TIME Stop at time
--prebuffer=TIME Start recording by a command from user, saving the previously bufferred seconds of audio
Expand Down
1 change: 1 addition & 0 deletions src/core-cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef struct fmed_cmd {
uint64 fseek;
ffstr meta;
ffarr2 include_files; //ffstr[]
ffarr2 exclude_files; //ffstr[]

float gain;
byte volume;
Expand Down
1 change: 1 addition & 0 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ static void cmd_destroy(fmed_cmd *cmd)
ffmem_safefree(cmd->globcmd_pipename);
ffstr_free(&cmd->globcmd);
ffarr2_free(&cmd->include_files);
ffarr2_free(&cmd->exclude_files);
}

static int conf_init(fmed_config *conf)
Expand Down
1 change: 1 addition & 0 deletions src/fmedia.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ struct fmed_trk {
float a_stop_level; //dB
uint a_stop_level_time; //msec
ffarr2 include_files; //ffstr[]
ffarr2 exclude_files; //ffstr[]
};

enum FMED_R {
Expand Down
7 changes: 6 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static const ffpars_arg fmed_cmdline_args[] = {
{ "mix", FFPARS_TBOOL8 | FFPARS_FALONE, OFF(mix) },
{ "flist", FFPARS_TCHARPTR | FFPARS_FSTRZ | FFPARS_FCOPY | FFPARS_FNOTEMPTY | FFPARS_FMULTI, FFPARS_DST(&arg_flist) },
{ "include", FFPARS_TSTR | FFPARS_FCOPY | FFPARS_FNOTEMPTY, FFPARS_DST(&arg_finclude) },
{ "exclude", FFPARS_TSTR | FFPARS_FCOPY | FFPARS_FNOTEMPTY, FFPARS_DST(&arg_finclude) },
{ "seek", FFPARS_TSTR | FFPARS_FNOTEMPTY, FFPARS_DST(&fmed_arg_seek) },
{ "until", FFPARS_TSTR | FFPARS_FNOTEMPTY, FFPARS_DST(&fmed_arg_seek) },
{ "prebuffer", FFPARS_TSTR | FFPARS_FNOTEMPTY, FFPARS_DST(&fmed_arg_seek) },
Expand Down Expand Up @@ -336,7 +337,10 @@ static int arg_finclude(ffparser_schem *p, void *obj, const ffstr *val)
*dst = wc;
}

ffarr_set(&cmd->include_files, a.ptr, a.len);
if (ffsz_eq(p->curarg->name, "include"))
ffarr_set(&cmd->include_files, a.ptr, a.len);
else
ffarr_set(&cmd->exclude_files, a.ptr, a.len);
ffarr_null(&a);
rc = 0;

Expand Down Expand Up @@ -616,6 +620,7 @@ static void trk_prep(fmed_cmd *fmed, fmed_trk *trk)
{
trk->input_info = fmed->info;
trk->include_files = fmed->include_files;
trk->exclude_files = fmed->exclude_files;
if (fmed->fseek != 0)
trk->input.seek = fmed->fseek;
if (fmed->seek_time != 0)
Expand Down
11 changes: 11 additions & 0 deletions src/plist.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@ static void* dir_open(fmed_filt *d)
}

/**
'include' filter matches files only.
'exclude' filter matches files & directories.
Return TRUE if filename matches user's filename wildcards. */
static ffbool file_matches(fmed_filt *d, const char *fn, ffbool dir)
{
Expand All @@ -672,6 +674,15 @@ static ffbool file_matches(fmed_filt *d, const char *fn, ffbool dir)
break;
}
}
if (!ok)
return 0;
}

FFARR_WALKT(&d->exclude_files, wc, ffstr) {
if (0 == ffs_wildcard(wc->ptr, wc->len, fn, fnlen, FFS_WC_ICASE)) {
ok = 0;
break;
}
}
return ok;
}
Expand Down
1 change: 1 addition & 0 deletions src/track.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ static void trk_copy_info(fmed_trk *dst, const fmed_trk *src)
dst->a_stop_level = src->a_stop_level;
dst->a_stop_level_time = src->a_stop_level_time;
dst->include_files = src->include_files;
dst->exclude_files = src->exclude_files;
dst->bits = src->bits;
}

Expand Down

0 comments on commit a3a5405

Please sign in to comment.