[GRASS-SVN] r68433 - in grass/trunk: include/defs lib/imagery

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 15 05:37:40 PDT 2016


Author: marisn
Date: 2016-05-15 05:37:40 -0700 (Sun, 15 May 2016)
New Revision: 68433

Modified:
   grass/trunk/include/defs/imagery.h
   grass/trunk/lib/imagery/find.c
Log:
imagery lib: Use HOST_DIRSEP instead of hardcoded value; New function to find signature files (required for #3000)

Modified: grass/trunk/include/defs/imagery.h
===================================================================
--- grass/trunk/include/defs/imagery.h	2016-05-15 12:31:24 UTC (rev 68432)
+++ grass/trunk/include/defs/imagery.h	2016-05-15 12:37:40 UTC (rev 68433)
@@ -21,6 +21,7 @@
 int I_find_group_file(const char *, const char *);
 int I_find_subgroup(const char *, const char *);
 int I_find_subgroup_file(const char *, const char *, const char *);
+int I_find_signature_file(const char *, const char *, const char *, const char *);
 
 /* fopen.c */
 FILE *I_fopen_group_file_new(const char *, const char *);

Modified: grass/trunk/lib/imagery/find.c
===================================================================
--- grass/trunk/lib/imagery/find.c	2016-05-15 12:31:24 UTC (rev 68432)
+++ grass/trunk/lib/imagery/find.c	2016-05-15 12:37:40 UTC (rev 68433)
@@ -45,7 +45,8 @@
     if (subgroup == NULL || *subgroup == 0)
         return 0;
 
-    sprintf(element, "subgroup/%s", subgroup);
+    sprintf(element, "subgroup%c%s", HOST_DIRSEP, subgroup);
+    G_debug(5, "I_find_subgroup() element: %s", element);
 
     return G_find_file2_misc("group", element, group, G_mapset()) != NULL;
 }
@@ -62,7 +63,43 @@
     if (file == NULL || *file == 0)
         return 0;
 
-    sprintf(element, "subgroup/%s/%s", subgroup, file);
+    sprintf(element, "subgroup%c%s%c%s", HOST_DIRSEP, subgroup, HOST_DIRSEP, file);
+    G_debug(5, "I_find_subgroup_file() element: %s", element);
 
     return G_find_file2_misc("group", element, group, G_mapset()) != NULL;
 }
+
+/*!
+ * \brief does signature file exists?
+ *
+ * Returns 1 if the
+ * specified <b>signature</b> exists in the specified subgroup; 0 otherwise.
+ * 
+ * Should be used to check if signature file exists after G_parser run
+ * when generating new signature file.
+ *
+ *  \param group - group where to search
+ *  \param subgroup - subgroup containing signatures
+ *  \param type - type of signature ("sig" or "sigset")
+ *  \param file - name of signature file
+ *  \return int
+ */
+int I_find_signature_file(const char *group, const char *subgroup,
+                     const char *type, const char *file)
+{
+    char element[GNAME_MAX * 2];
+    
+    if (!I_find_group(group))
+        return 0;
+    if (subgroup == NULL || *subgroup == 0)
+        return 0;
+    if (type == NULL || *type == 0)
+        return 0;
+    if (file == NULL || *file == 0)
+        return 0;
+        
+    sprintf(element, "subgroup%c%s%c%s%c%s", HOST_DIRSEP, subgroup, HOST_DIRSEP, type, HOST_DIRSEP, file);
+    G_debug(5, "I_find_signature_file() element: %s", element);
+    
+    return G_find_file2_misc("group", element, group, G_mapset()) != NULL;
+}



More information about the grass-commit mailing list