Closed zordtk closed 3 years ago
Thanks for the PR. I believe using glob
is a bit of an overkill in this situation. I think fnmatch
could be sufficient. Furthermore, you probably forgot to add your modifications in mktorrent.h
to the commit because it does not build.
In file included from mktorrent.h:29,
from ftw.c:33:
ftw.c: In function ‘file_tree_walk’:
ftw.c:193:21: error: ‘struct metafile’ has no member named ‘exclude_list’
193 | LL_FOR(tier_node, m->exclude_list) {
| ^~
ll.h:32:81: note: in definition of macro ‘LL_FOR_FROM_TO_STEP’
32 | #define LL_FOR_FROM_TO_STEP(node, from, to, step) for (struct ll_node *(node) = from; node != to; step(node))
| ^~~~
ll.h:33:54: note: in expansion of macro ‘LL_HEAD’
33 | #define LL_FOR(node, list) LL_FOR_FROM_TO_STEP(node, LL_HEAD(list), NULL, LL_STEP)
| ^~~~~~~
ftw.c:193:2: note: in expansion of macro ‘LL_FOR’
193 | LL_FOR(tier_node, m->exclude_list) {
| ^~~~~~
Sorry, included mktorrent.h. Thanks for your comments, I will change it to use fnmatch instead of glob.
I rewrote it to use fnmatch, it simplified things and removed the need for second linked list.
Edit: Should I enable the FNM_EXTMATCH flag for additional matching options?
This adds a exclude option to mktorrent. It allows you to exclude files based on a glob string:
example: mktorrent -e *.nfo
You can pass multiple -e flags or separate them by commas
example: mktorrent -e *.nfo,*.jpg
I'm not sure if the first one is a good example, since the shell might expand the pattern before running the program, and then user will be surprised.
Edit: Should I enable the FNM_EXTMATCH flag for additional matching options?
I'm not sure about that.
I'm not sure if the first one is a good example, since the shell might expand the pattern before running the program, and then user will be surprised.
What would be your suggestion for an example? I haven't ran into that issue with bash. Although I'm mostly using this in a shell script to auto-create torrents.
I'm not sure about that.
Ok, I'll leave it disabled.
Consider the following:
$ ls
a.jpg b.jpg c.png d.png
$ set -x
[...]
$ mktorrent -e *.jpg .
+ mktorrent -e a.jpg b.jpg .
mktorrent 1.1 (c) 2007, 2009 Emil Renner Berthing
hashing b.jpg
writing metainfo file... done
mktorrent
will be called as mktorrent -e a.jpg b.jpg .
. Of course, this is a minor thing, and the example is not in any piece of documentation, yet, but I wanted to bring attention to it nonetheless.
Hopefully I didn't miss anything. Thanks again.
This adds a exclude option to mktorrent. It allows you to exclude files based on a glob string:
example: mktorrent -e *.nfo
You can pass multiple -e flags or separate them by commas
example: mktorrent -e *.nfo,*.jpg