mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-07 22:03:24 +00:00
Fix annoyances on file.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
beb0bc7a1d
commit
04e39704e2
3 changed files with 11 additions and 8 deletions
|
@ -86,7 +86,7 @@ static void zip_read(struct zip_file *file, const char *filename)
|
||||||
free(mem);
|
free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
int try_to_open_zip(const char *filename, struct memblock *mem)
|
int try_to_open_zip(const char *filename)
|
||||||
{
|
{
|
||||||
int success = 0;
|
int success = 0;
|
||||||
/* Grr. libzip needs to re-open the file, it can't take a buffer */
|
/* Grr. libzip needs to re-open the file, it can't take a buffer */
|
||||||
|
@ -164,6 +164,9 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons
|
||||||
|
|
||||||
int db_test_func(void *param, int columns, char **data, char **column)
|
int db_test_func(void *param, int columns, char **data, char **column)
|
||||||
{
|
{
|
||||||
|
(void) param;
|
||||||
|
(void) columns;
|
||||||
|
(void) column;
|
||||||
return *data[0] == '0';
|
return *data[0] == '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +338,7 @@ static void add_sample_data(struct sample *sample, enum csv_format type, double
|
||||||
*
|
*
|
||||||
* Followed by the data values (all comma-separated, all one long line).
|
* Followed by the data values (all comma-separated, all one long line).
|
||||||
*/
|
*/
|
||||||
static int try_to_open_csv(const char *filename, struct memblock *mem, enum csv_format type)
|
static int try_to_open_csv(struct memblock *mem, enum csv_format type)
|
||||||
{
|
{
|
||||||
char *p = mem->buffer;
|
char *p = mem->buffer;
|
||||||
char *header[8];
|
char *header[8];
|
||||||
|
@ -398,7 +401,7 @@ static int open_by_filename(const char *filename, const char *fmt, struct memblo
|
||||||
|
|
||||||
/* Suunto Dive Manager files: SDE, ZIP; divelogs.de files: DLD */
|
/* Suunto Dive Manager files: SDE, ZIP; divelogs.de files: DLD */
|
||||||
if (!strcasecmp(fmt, "SDE") || !strcasecmp(fmt, "ZIP") || !strcasecmp(fmt, "DLD"))
|
if (!strcasecmp(fmt, "SDE") || !strcasecmp(fmt, "ZIP") || !strcasecmp(fmt, "DLD"))
|
||||||
return try_to_open_zip(filename, mem);
|
return try_to_open_zip(filename);
|
||||||
|
|
||||||
/* CSV files */
|
/* CSV files */
|
||||||
if (!strcasecmp(fmt, "CSV"))
|
if (!strcasecmp(fmt, "CSV"))
|
||||||
|
@ -408,13 +411,13 @@ static int open_by_filename(const char *filename, const char *fmt, struct memblo
|
||||||
return try_to_open_cochran(filename, mem);
|
return try_to_open_cochran(filename, mem);
|
||||||
/* Cochran export comma-separated-value files */
|
/* Cochran export comma-separated-value files */
|
||||||
if (!strcasecmp(fmt, "DPT"))
|
if (!strcasecmp(fmt, "DPT"))
|
||||||
return try_to_open_csv(filename, mem, CSV_DEPTH);
|
return try_to_open_csv(mem, CSV_DEPTH);
|
||||||
if (!strcasecmp(fmt, "LVD"))
|
if (!strcasecmp(fmt, "LVD"))
|
||||||
return try_to_open_liquivision(filename, mem);
|
return try_to_open_liquivision(filename, mem);
|
||||||
if (!strcasecmp(fmt, "TMP"))
|
if (!strcasecmp(fmt, "TMP"))
|
||||||
return try_to_open_csv(filename, mem, CSV_TEMP);
|
return try_to_open_csv(mem, CSV_TEMP);
|
||||||
if (!strcasecmp(fmt, "HP1"))
|
if (!strcasecmp(fmt, "HP1"))
|
||||||
return try_to_open_csv(filename, mem, CSV_PRESSURE);
|
return try_to_open_csv(mem, CSV_PRESSURE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
extern int readfile(const char *filename, struct memblock *mem);
|
extern int readfile(const char *filename, struct memblock *mem);
|
||||||
extern timestamp_t parse_date(const char *date);
|
extern timestamp_t parse_date(const char *date);
|
||||||
extern int try_to_open_zip(const char *filename, struct memblock *mem);
|
extern int try_to_open_zip(const char *filename);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -364,7 +364,7 @@ void TestParse::testParseDLD()
|
||||||
QString filename = SUBSURFACE_SOURCE "/dives/TestDiveDivelogsDE.DLD";
|
QString filename = SUBSURFACE_SOURCE "/dives/TestDiveDivelogsDE.DLD";
|
||||||
|
|
||||||
QVERIFY(readfile(filename.toLatin1().data(), &mem) > 0);
|
QVERIFY(readfile(filename.toLatin1().data(), &mem) > 0);
|
||||||
QVERIFY(try_to_open_zip(filename.toLatin1().data(), &mem) > 0);
|
QVERIFY(try_to_open_zip(filename.toLatin1().data()) > 0);
|
||||||
|
|
||||||
fprintf(stderr, "number of dives from DLD: %d \n", dive_table.nr);
|
fprintf(stderr, "number of dives from DLD: %d \n", dive_table.nr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue