#include <glib/gstdio.h>
#include <glib/gi18n.h>
+#include "file.h"
+
#define TEST_BOOLEAN(str) (! ((str)[0] == '\0' || (str)[0] == '0' || (str)[0] == 'n' || (str)[0] == 'N' || (str)[0] == 'f' || (str)[0] == 'F') )
#define VIK_MAGIC "#VIK"
#define GPX_MAGIC "<?xm"
#define VIK_MAGIC_LEN 4
-#ifdef WINDOWS
-#define FILE_SEP '\\'
-#else
-#define FILE_SEP '/'
-#endif
-
#define VIKING_FILE_VERSION 1
typedef struct _Stack Stack;
case VIK_LAYER_PARAM_UINT: fprintf ( f, "%d\n", data.u ); break;
case VIK_LAYER_PARAM_INT: fprintf ( f, "%d\n", data.i ); break;
case VIK_LAYER_PARAM_BOOLEAN: fprintf ( f, "%c\n", data.b ? 't' : 'f' ); break;
- case VIK_LAYER_PARAM_STRING: fprintf ( f, "%s\n", data.s ); break;
+ case VIK_LAYER_PARAM_STRING: fprintf ( f, "%s\n", data.s ? data.s : "" ); break;
case VIK_LAYER_PARAM_COLOR: fprintf ( f, "#%.2x%.2x%.2x\n", (int)(data.c.red/256),(int)(data.c.green/256),(int)(data.c.blue/256)); break;
default: break;
}
g_return_val_if_fail ( vp != NULL, LOAD_TYPE_READ_FAILURE );
char *filename = (char *)filename_or_uri;
- if (strncmp(filename, "file://", 7) == 0)
+ if (strncmp(filename, "file://", 7) == 0) {
+ // Consider replacing this with:
+ // filename = g_filename_from_uri ( entry, NULL, NULL );
+ // Since this doesn't support URIs properly (i.e. will failure if is it has %20 characters in it)
filename = filename + 7;
-
+ g_debug ( "Loading file %s from URI %s", filename, filename_or_uri );
+ }
FILE *f = xfopen ( filename, "r" );
if ( ! f )
{
const gchar *t = filename + strlen(filename) - 1;
while ( --t > filename )
- if ( *(t-1) == FILE_SEP )
+ if ( *(t-1) == G_DIR_SEPARATOR )
break;
if ( t >= filename )
return t;