123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #include <stdio.h>
- #include <grass/gis.h>
- #include <grass/imagery.h>
- #include <grass/glocale.h>
- /******************************************************
- * I_fopen_group_file_new()
- * I_fopen_group_file_append()
- * I_fopen_group_file_old()
- *
- * fopen new group files in the current mapset
- * fopen old group files anywhere
- *******************************************************/
- FILE *I_fopen_group_file_new(const char *group, const char *file)
- {
- FILE *fd;
- 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());
- return fd;
- }
- FILE *I_fopen_group_file_append(const char *group, const char *file)
- {
- FILE *fd;
- 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());
- return fd;
- }
- FILE *I_fopen_group_file_old(const char *group, const char *file)
- {
- FILE *fd;
- /* find file first */
- if (!I_find_group_file(group, file)) {
- G_warning(_("Unable to find file [%s] of group [%s in %s]"),
- file, group, G_mapset());
- return ((FILE *) NULL);
- }
- 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());
- return fd;
- }
- FILE *I_fopen_subgroup_file_new(const char *group,
- const char *subgroup, const char *file)
- {
- FILE *fd;
- char element[GNAME_MAX * 2];
- /* create subgroup directory */
- sprintf(element, "%s/subgroup/%s", group, subgroup);
- G__make_mapset_element_misc("group", element);
- /* get subgroup element name */
- sprintf(element, "subgroup/%s/%s", subgroup, 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());
- return fd;
- }
- FILE *I_fopen_subgroup_file_append(const char *group,
- const char *subgroup, const char *file)
- {
- FILE *fd;
- char element[GNAME_MAX * 2];
- /* create subgroup directory */
- sprintf(element, "%s/subgroup/%s", group, subgroup);
- G__make_mapset_element_misc("group", element);
- /* get subgroup element name */
- sprintf(element, "subgroup/%s/%s", subgroup, 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());
- return fd;
- }
- FILE *I_fopen_subgroup_file_old(const char *group,
- const char *subgroup, const char *file)
- {
- FILE *fd;
- char element[GNAME_MAX * 2];
- /* find file first */
- if (!I_find_subgroup_file(group, subgroup, file)) {
- G_warning(_("Unable to find file [%s] for subgroup [%s] of group [%s in %s]"),
- file, subgroup, group, G_mapset());
- return ((FILE *) NULL);
- }
- /* get subgroup element name */
- sprintf(element, "subgroup/%s/%s", subgroup, file);
- 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());
- return fd;
- }
|