[MPlayer-dev-eng] [PATCH] dirname not found on BSD/OS

Steven M. Schultz sms at 2BSD.COM
Mon Jan 6 01:30:58 CET 2003


Hi -

	I was redirected here from -users for this - so here goes.

	Apparently BSD/OS lacks dirname(3) (dirname(1) is present)

	Looking at the linux manpage for dirname I've come up with an
	inline replacement that should be equivalent in behaviour.   Handling
	the no slash and only a slash contributed to the extra few lines ;)

	Steven Schultz
	sms at 2bsd.com

------------------------snip------------
--- libmpdemux/cue_read.c.dist	Sun Jan  5 15:51:05 2003
+++ libmpdemux/cue_read.c	Sun Jan  5 16:25:40 2003
@@ -8,7 +8,9 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
+#ifdef	__linux__
 #include <libgen.h>
+#endif
 
 #include "config.h"
 #include "mp_msg.h"
@@ -291,7 +293,15 @@
 
   /* split the filename into a path and filename part */
   s = strdup(in_cue_filename);
-  t = dirname(s);
+  t = strrchr(s, '/');
+  if (t == (char *)NULL)
+     t = ".";
+  else {
+     *t = '\0';
+     t = s;
+     if (*t)
+	strcpy(t, "/");
+  }
   printf ("dirname: %s\n", t);
   strcpy(bincue_path,t);
 


More information about the MPlayer-dev-eng mailing list