diff options
author | Thomas White <taw@physics.org> | 2020-05-04 16:59:44 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:42:57 +0200 |
commit | a170c8d8f69f8682a17869a809aaede036fb0254 (patch) | |
tree | ea64d6e7dd8c85b3588758eb4f5f4d63a72731da /src | |
parent | 26861a1ad1d3854e3f0acc9479fd5f5cc1135bdd (diff) |
Move match_filename() to gui_project
Diffstat (limited to 'src')
-rw-r--r-- | src/crystfel_gui.c | 26 | ||||
-rw-r--r-- | src/gui_project.c | 26 | ||||
-rw-r--r-- | src/gui_project.h | 2 |
3 files changed, 28 insertions, 26 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 6838dcf8..9718e9f5 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -96,32 +96,6 @@ static void update_imageview(struct crystfelproject *proj) } -static int match_filename(const char *fn, enum match_type_id mt) -{ - const char *ext = NULL; - const char *ext2 = NULL; - - 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)); - } - if ( mt == MATCH_CHEETAH_CXI ) return strcmp(ext, ".cxi")==0; - if ( mt == MATCH_CBF ) return strcmp(ext, ".cbf")==0; - if ( mt == MATCH_CBFGZ ) { - if ( ext2 != NULL ) { - return strcmp(ext2, ".cbf.gz")==0; - } - } - - return 0; -} - - static void add_files(struct crystfelproject *proj, GFile *folder, enum match_type_id type) { diff --git a/src/gui_project.c b/src/gui_project.c index 4effc603..fcfce995 100644 --- a/src/gui_project.c +++ b/src/gui_project.c @@ -89,6 +89,32 @@ enum match_type_id decode_matchtype(const char *type_id) } +int match_filename(const char *fn, enum match_type_id mt) +{ + const char *ext = NULL; + const char *ext2 = NULL; + + 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)); + } + if ( mt == MATCH_CHEETAH_CXI ) return strcmp(ext, ".cxi")==0; + if ( mt == MATCH_CBF ) return strcmp(ext, ".cbf")==0; + if ( mt == MATCH_CBFGZ ) { + if ( ext2 != NULL ) { + return strcmp(ext2, ".cbf.gz")==0; + } + } + + return 0; +} + + static void handle_var(const char *key, const char *val, struct crystfelproject *proj) { diff --git a/src/gui_project.h b/src/gui_project.h index 1c99d5ce..77936f2a 100644 --- a/src/gui_project.h +++ b/src/gui_project.h @@ -110,6 +110,8 @@ struct crystfelproject { extern enum match_type_id decode_matchtype(const char *type_id); +extern int match_filename(const char *fn, enum match_type_id mt); + extern int load_project(struct crystfelproject *proj); extern void add_file_to_project(struct crystfelproject *proj, |