[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master e4f7bc7: Compression suffixes accounted for in
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master e4f7bc7: Compression suffixes accounted for in automatic output |
Date: |
Wed, 16 Nov 2016 23:18:55 +0000 (UTC) |
branch: master
commit e4f7bc7afa56cfc5a83945bf24d09ed15f1b13fc
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Compression suffixes accounted for in automatic output
The `gal_checkset_automatic_output' function is in charge of setting the
filename of the output filename when the user hasn't specified any.
It starts from the end of the input file name and replaces everything
including and after the first `.' it encounters. This works on ordinary
`.fits' files, but not on inputs like `.fits.gz' (that CFITSIO also
accepts). So for example ConvertType's default output (to convert to Jpeg)
on such a file would end with `.fits.jpg'. With this commit, some further
checks are added to see if the text after the last `.' is a compression
suffix or not. If so, it continues going down the filename in search of the
next `.'. This is not the most elegent solution, but with the current
implementation of `gal_checkset_automatic_output', this was the best
solution I could find right now.
This fixes bug #49629.
---
lib/checkset.c | 9 ++++++++-
lib/fits.c | 9 +++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/lib/checkset.c b/lib/checkset.c
index 0a309a7..cacacee 100644
--- a/lib/checkset.c
+++ b/lib/checkset.c
@@ -835,7 +835,14 @@ gal_checkset_automatic_output(char *inname, char *suffix,
int removedirinfo,
out[i+1]='\0';
break;
}
- else if(out[i]=='.')
+
+ /* The input file names can be compressed names (for example
+ `.fits.gz'). Currently the only compressed formats
+ (decompressed within CFITSIO) are listed in
+ `gal_fits_name_is_fits' and `gal_fits_suffix_is_fits'.*/
+ else if(out[i]=='.' && !( ( out[i+1]=='g' && out[i+2]=='z' )
+ || (out[i+1]=='f' && out[i+2]=='z' )
+ || out[i+1]=='Z' ) )
{
out[i]='\0';
strcat(out, suffix);
diff --git a/lib/fits.c b/lib/fits.c
index 494f833..be47af8 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -76,6 +76,11 @@ gal_fits_io_error(int status, char *message)
/*************************************************************
************** Acceptable FITS names ***************
*************************************************************/
+
+/* IMPORTANT NOTE: if other compression suffixes are add to this function,
+ include them in `gal_checkset_automatic_output', so the compression
+ suffix can be skipped when the user doesn't specify an output
+ filename.*/
int
gal_fits_name_is_fits(char *name)
{
@@ -95,6 +100,10 @@ gal_fits_name_is_fits(char *name)
+/* IMPORTANT NOTE: if other compression suffixes are add to this function,
+ include them in `gal_checkset_automatic_output', so the compression
+ suffix can be skipped when the user doesn't specify an output
+ filename.*/
int
gal_fits_suffix_is_fits(char *suffix)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master e4f7bc7: Compression suffixes accounted for in automatic output,
Mohammad Akhlaghi <=