mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[gz_open] Use compress and write consistent with calling functions.
This commit is contained in:
parent
8e4c4948cc
commit
d7eae0664f
@ -95,7 +95,7 @@ typedef struct
|
|||||||
gint fd;
|
gint fd;
|
||||||
gchar* filename;
|
gchar* filename;
|
||||||
gchar* perms;
|
gchar* perms;
|
||||||
gboolean compress;
|
gboolean write;
|
||||||
} gz_thread_params_t;
|
} gz_thread_params_t;
|
||||||
|
|
||||||
/* Callback structure */
|
/* Callback structure */
|
||||||
@ -125,8 +125,8 @@ gnc_v2_book_version_string; /* see gnc-book-xml-v2 */
|
|||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
static FILE* try_gz_open (const char* filename, const char* perms,
|
static FILE* try_gz_open (const char* filename, const char* perms,
|
||||||
gboolean use_gzip,
|
gboolean compress,
|
||||||
gboolean compress);
|
gboolean write);
|
||||||
static gboolean is_gzipped_file (const gchar* name);
|
static gboolean is_gzipped_file (const gchar* name);
|
||||||
static gboolean wait_for_gzip (FILE* file);
|
static gboolean wait_for_gzip (FILE* file);
|
||||||
|
|
||||||
@ -1433,7 +1433,7 @@ gz_thread_func (gz_thread_params_t* params)
|
|||||||
goto cleanup_gz_thread_func;
|
goto cleanup_gz_thread_func;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params->compress)
|
if (params->write)
|
||||||
{
|
{
|
||||||
while (success)
|
while (success)
|
||||||
{
|
{
|
||||||
@ -1514,13 +1514,13 @@ cleanup_gz_thread_func:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static FILE*
|
static FILE*
|
||||||
try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
|
try_gz_open (const char* filename, const char* perms, gboolean compress,
|
||||||
gboolean compress)
|
gboolean write)
|
||||||
{
|
{
|
||||||
if (strstr (filename, ".gz.") != NULL) /* its got a temp extension */
|
if (strstr (filename, ".gz.") != NULL) /* its got a temp extension */
|
||||||
use_gzip = TRUE;
|
compress = TRUE;
|
||||||
|
|
||||||
if (!use_gzip)
|
if (!compress)
|
||||||
return g_fopen (filename, perms);
|
return g_fopen (filename, perms);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1554,10 +1554,10 @@ try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
|
|||||||
}
|
}
|
||||||
|
|
||||||
params = g_new (gz_thread_params_t, 1);
|
params = g_new (gz_thread_params_t, 1);
|
||||||
params->fd = filedes[compress ? 0 : 1];
|
params->fd = filedes[write ? 0 : 1];
|
||||||
params->filename = g_strdup (filename);
|
params->filename = g_strdup (filename);
|
||||||
params->perms = g_strdup (perms);
|
params->perms = g_strdup (perms);
|
||||||
params->compress = compress;
|
params->write = write;
|
||||||
|
|
||||||
thread = g_thread_new ("xml_thread", (GThreadFunc) gz_thread_func,
|
thread = g_thread_new ("xml_thread", (GThreadFunc) gz_thread_func,
|
||||||
params);
|
params);
|
||||||
@ -1573,7 +1573,7 @@ try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
|
|||||||
return g_fopen (filename, perms);
|
return g_fopen (filename, perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compress)
|
if (write)
|
||||||
file = fdopen (filedes[1], "w");
|
file = fdopen (filedes[1], "w");
|
||||||
else
|
else
|
||||||
file = fdopen (filedes[0], "r");
|
file = fdopen (filedes[0], "r");
|
||||||
|
Loading…
Reference in New Issue
Block a user