aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-03-20 14:13:17 +0100
committerThomas White <taw@physics.org>2020-07-29 18:42:57 +0200
commit926267d69531e5d1f936231f4e01971e7f31b8e9 (patch)
treee0c51830aba2b596b6f73d42ace309ce50f75b32 /src
parent5543f048ba45e07238cf5b16bc778305a7db2be1 (diff)
Factorise filename_extension()
Diffstat (limited to 'src')
-rw-r--r--src/crystfel_gui.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index db2fc1b3..a567ddcf 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -109,23 +109,12 @@ static int match_filename(const char *fn, enum match_type_id mt)
{
const char *ext = NULL;
const char *ext2 = NULL;
- size_t r = strlen(fn)-1;
-
- while ( r > 0 ) {
- if ( fn[r] == '.' ) {
- if ( ext != NULL ) {
- ext2 = fn+r;
- break;
- } else {
- ext = fn+r;
- }
- }
- r--;
- }
if ( mt == MATCH_EVERYTHING ) return 1;
+ ext = filename_extension(fn, &ext2);
if ( ext == NULL ) return 0;
+
if ( mt == MATCH_CHEETAH_LCLS_H5 ) {
return ((strcmp(ext, ".h5")==0)
&& (strncmp(fn, "LCLS", 4)==0));