[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19131 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19131 - in gnunet/src: include util |
Date: |
Sat, 14 Jan 2012 16:17:08 +0100 |
Author: grothoff
Date: 2012-01-14 16:17:08 +0100 (Sat, 14 Jan 2012)
New Revision: 19131
Modified:
gnunet/src/include/gnunet_strings_lib.h
gnunet/src/util/strings.c
Log:
LRN: add function GNUNET_STRINGS_get_short_name to get basename
Modified: gnunet/src/include/gnunet_strings_lib.h
===================================================================
--- gnunet/src/include/gnunet_strings_lib.h 2012-01-13 22:14:11 UTC (rev
19130)
+++ gnunet/src/include/gnunet_strings_lib.h 2012-01-14 15:17:08 UTC (rev
19131)
@@ -199,6 +199,20 @@
char *
GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta);
+/**
+ * "man basename"
+ * Returns a pointer to a part of filename (allocates nothing)!
+ *
+ * @param filename filename to extract basename from
+ * @return short (base) name of the file (that is, everything following the
+ * last directory separator in filename. If filename ends with a
+ * directory separator, the result will be a zero-length string.
+ * If filename has no directory separators, the result is filename
+ * itself.
+ */
+const char *
+GNUNET_STRINGS_get_short_name (const char *filename);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
Modified: gnunet/src/util/strings.c
===================================================================
--- gnunet/src/util/strings.c 2012-01-13 22:14:11 UTC (rev 19130)
+++ gnunet/src/util/strings.c 2012-01-14 15:17:08 UTC (rev 19131)
@@ -607,6 +607,26 @@
return ret;
}
+/**
+ * "man basename"
+ * Returns a pointer to a part of filename (allocates nothing)!
+ *
+ * @param filename filename to extract basename from
+ * @return short (base) name of the file (that is, everything following the
+ * last directory separator in filename. If filename ends with a
+ * directory separator, the result will be a zero-length string.
+ * If filename has no directory separators, the result is filename
+ * itself.
+ */
+const char *
+GNUNET_STRINGS_get_short_name (const char *filename)
+{
+ const char *short_fn = filename;
+ const char *ss;
+ while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))
+ && (ss[1] != '\0'))
+ short_fn = 1 + ss;
+ return short_fn;
+}
-
/* end of strings.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19131 - in gnunet/src: include util,
gnunet <=