[GRASS-SVN] r30948 - grass/trunk/lib/imagery
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 11 23:05:10 EDT 2008
Author: glynn
Date: 2008-04-11 23:04:46 -0400 (Fri, 11 Apr 2008)
New Revision: 30948
Modified:
grass/trunk/lib/imagery/find.c
grass/trunk/lib/imagery/fopen.c
grass/trunk/lib/imagery/sigfile.c
grass/trunk/lib/imagery/sigsetfile.c
Log:
Fix handling of group elements to cope with @mapset
Modified: grass/trunk/lib/imagery/find.c
===================================================================
--- grass/trunk/lib/imagery/find.c 2008-04-12 03:03:06 UTC (rev 30947)
+++ grass/trunk/lib/imagery/find.c 2008-04-12 03:04:46 UTC (rev 30948)
@@ -27,17 +27,12 @@
int I_find_group_file(char *group, char *file)
{
- char element[GNAME_MAX];
-
if (!I_find_group (group))
return 0;
if (file == NULL || *file == 0)
return 0;
- sprintf (element, "group/%s", group);
- G_debug(4, "I_find_group_file: element <%s>", element);
-
- return G_find_file (element, file, G_mapset()) != NULL ;
+ return G_find_file2_misc ("group", file, group, G_mapset()) != NULL ;
}
int I_find_subgroup(char *group, char *subgroup)
@@ -49,9 +44,9 @@
if (subgroup == NULL || *subgroup == 0)
return 0;
- sprintf (element, "group/%s/subgroup", group);
+ sprintf (element, "subgroup/%s", subgroup);
- return G_find_file (element, subgroup, G_mapset()) != NULL ;
+ return G_find_file2_misc ("group", element, group, G_mapset()) != NULL ;
}
int I_find_subgroup_file(char *group, char *subgroup, char *file)
@@ -65,7 +60,7 @@
if (file == NULL || *file == 0)
return 0;
- sprintf (element, "group/%s/subgroup/%s", group, subgroup);
+ sprintf (element, "subgroup/%s/%s", subgroup, file);
- return G_find_file (element, file, G_mapset()) != NULL ;
+ return G_find_file2_misc ("group", element, group, G_mapset()) != NULL ;
}
Modified: grass/trunk/lib/imagery/fopen.c
===================================================================
--- grass/trunk/lib/imagery/fopen.c 2008-04-12 03:03:06 UTC (rev 30947)
+++ grass/trunk/lib/imagery/fopen.c 2008-04-12 03:04:46 UTC (rev 30948)
@@ -18,12 +18,8 @@
I_fopen_group_file_new(char *group, char *file)
{
FILE *fd;
- char element[GNAME_MAX];
- /* get group element name */
- sprintf (element, "group/%s", group);
-
- fd = G_fopen_new (element, file);
+ fd = G_fopen_new_misc ("group", file, group);
if (!fd)
G_warning (_("Unable to create file [%s] of group [%s in %s]"),
file, group, G_mapset());
@@ -36,12 +32,8 @@
I_fopen_group_file_append (char *group, char *file)
{
FILE *fd;
- char element[GNAME_MAX];
- /* get group element name */
- sprintf (element, "group/%s", group);
-
- fd = G_fopen_append (element, file);
+ fd = G_fopen_append_misc ("group", file, group);
if (!fd)
G_warning (_("Unable to open file [%s] of group [%s in %s]"),
file, group, G_mapset());
@@ -54,7 +46,6 @@
I_fopen_group_file_old (char *group, char *file)
{
FILE *fd;
- char element[GNAME_MAX];
/* find file first */
if (!I_find_group_file (group, file))
@@ -65,10 +56,7 @@
return ((FILE *) NULL);
}
- /* get group element name */
- sprintf (element, "group/%s", group);
-
- fd = G_fopen_old (element, file, G_mapset());
+ fd = G_fopen_old_misc ("group", file, group, G_mapset());
if (!fd)
G_warning (_("Unable to open file [%s] of group [%s in %s]"),
file, group, G_mapset());
@@ -87,9 +75,9 @@
char element[GNAME_MAX*2];
/* get subgroup element name */
- sprintf (element, "group/%s/subgroup/%s", group, subgroup);
+ sprintf (element, "subgroup/%s/%s", subgroup, file);
- fd = G_fopen_new (element, file);
+ fd = G_fopen_new_misc ("group", element, group);
if (!fd)
G_warning (_("Unable to create file [%s] for subgroup [%s] of group [%s in %s]"),
file, subgroup, group, G_mapset());
@@ -108,9 +96,9 @@
char element[GNAME_MAX*2];
/* get subgroup element name */
- sprintf (element, "group/%s/subgroup/%s", group, subgroup);
+ sprintf (element, "subgroup/%s/%s", subgroup, file);
- fd = G_fopen_append (element, file);
+ fd = G_fopen_append_misc ("group", element, group);
if (!fd)
G_warning (_("Unable to open file [%s] for subgroup [%s] of group [%s in %s]"),
file, subgroup, group, G_mapset());
@@ -138,9 +126,9 @@
}
/* get subgroup element name */
- sprintf (element, "group/%s/subgroup/%s", group, subgroup);
+ sprintf (element, "subgroup/%s/%s", subgroup, file);
- fd = G_fopen_old (element, file, G_mapset());
+ fd = G_fopen_old_misc ("group", element, group, G_mapset());
if (!fd)
G_warning (_("Unable to open file [%s] for subgroup [%s] of group [%s in %s]"),
file, subgroup, group, G_mapset());
Modified: grass/trunk/lib/imagery/sigfile.c
===================================================================
--- grass/trunk/lib/imagery/sigfile.c 2008-04-12 03:03:06 UTC (rev 30947)
+++ grass/trunk/lib/imagery/sigfile.c 2008-04-12 03:04:46 UTC (rev 30948)
@@ -6,12 +6,12 @@
char *subgroup,
char *name)
{
- char element[200];
+ char element[GNAME_MAX*2];
FILE *fd;
- sprintf (element, "group/%s/subgroup/%s/sig", group, subgroup);
+ sprintf (element, "subgroup/%s/sig/%s", subgroup, name);
- fd = G_fopen_new (element, name);
+ fd = G_fopen_new_misc ("group", element, group);
if (fd == NULL)
G_warning ("unable to create signature file %s for subgroup %s of group %s",
name, subgroup, group);
@@ -23,12 +23,12 @@
char *subgroup,
char *name)
{
- char element[200];
+ char element[GNAME_MAX*2];
FILE *fd;
- sprintf (element, "group/%s/subgroup/%s/sig", group, subgroup);
+ sprintf (element, "subgroup/%s/sig/%s", subgroup, name);
- fd = G_fopen_old (element, name, G_mapset());
+ fd = G_fopen_old_misc ("group", element, group, G_mapset());
if (fd == NULL)
G_warning ("unable to open signature file %s for subgroup %s of group [%s in %s]",
name, subgroup, group, G_mapset());
Modified: grass/trunk/lib/imagery/sigsetfile.c
===================================================================
--- grass/trunk/lib/imagery/sigsetfile.c 2008-04-12 03:03:06 UTC (rev 30947)
+++ grass/trunk/lib/imagery/sigsetfile.c 2008-04-12 03:04:46 UTC (rev 30948)
@@ -2,36 +2,30 @@
FILE *I_fopen_sigset_file_new( char *group, char *subgroup, char *name)
{
- char element[200];
+ char element[GNAME_MAX*2];
FILE *fd;
- sprintf (element, "group/%s/subgroup/%s/sigset", group, subgroup);
+ sprintf (element, "subgroup/%s/sigset/%s", subgroup, name);
- fd = G_fopen_new (element, name);
+ fd = G_fopen_new_misc ("group", element, group);
if (fd == NULL)
- {
- char msg[200];
- sprintf (msg, "unable to create signature file %s for subgroup %s of group %s",
- name, subgroup, group);
- G_warning (msg);
- }
+ G_warning ("unable to create signature file %s for subgroup %s of group %s",
+ name, subgroup, group);
+
return fd;
}
FILE *I_fopen_sigset_file_old ( char *group, char *subgroup, char *name)
{
- char element[200];
+ char element[GNAME_MAX*2];
FILE *fd;
- sprintf (element, "group/%s/subgroup/%s/sigset", group, subgroup);
+ sprintf (element, "subgroup/%s/sigset/%s", subgroup, name);
- fd = G_fopen_old (element, name, G_mapset());
+ fd = G_fopen_old_misc ("group", element, group, G_mapset());
if (fd == NULL)
- {
- char msg[200];
- sprintf (msg, "unable to open signature file %s for subgroup %s of group [%s in %s]",
- name, subgroup, group, G_mapset());
- G_warning (msg);
- }
+ G_warning ("unable to open signature file %s for subgroup %s of group [%s in %s]",
+ name, subgroup, group, G_mapset());
+
return fd;
}
More information about the grass-commit
mailing list