Browse Source

Added strip_basename() function.

Helper function to determine the parent directory of a path.
Iain Patterson 10 years ago
parent
commit
bf75c3da8b
1 changed files with 9 additions and 0 deletions
  1. 9 0
      gui.cpp

+ 9 - 0
gui.cpp

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