Added strip_basename() function.
authorIain Patterson <me@iain.cx>
Wed, 20 Nov 2013 15:14:56 +0000 (15:14 +0000)
committerIain Patterson <me@iain.cx>
Wed, 20 Nov 2013 15:16:28 +0000 (15:16 +0000)
Helper function to determine the parent directory of a path.

gui.cpp

diff --git a/gui.cpp b/gui.cpp
index 5aaf016..5ceb33f 100644 (file)
--- a/gui.cpp
+++ b/gui.cpp
@@ -1,5 +1,14 @@
 #include "nssm.h"\r
 \r
+static void strip_basename(char *buffer) {\r
+  size_t len = strlen(buffer);\r
+  size_t i;\r
+  for (i = len; i && buffer[i] != '\\' && buffer[i] != '/'; i--);\r
+  /* X:\ is OK. */\r
+  if (i && buffer[i-1] == ':') i++;\r
+  buffer[i] = '\0';\r
+}\r
+\r
 int nssm_gui(int resource, char *name) {\r
   /* Create window */\r
   HWND dlg = CreateDialog(0, MAKEINTRESOURCE(resource), 0, install_dlg);\r