[Debtags-commits] [svn] r1611 - in tagcoll/trunk: debian tools

Enrico Zini enrico at costa.debian.org
Thu Mar 2 00:22:37 UTC 2006


Author: enrico
Date: Thu Mar  2 00:22:32 2006
New Revision: 1611

Modified:
   tagcoll/trunk/debian/rules
   tagcoll/trunk/tools/tagcoll.cc
Log:
Allow to use a directory with --patch-with

Modified: tagcoll/trunk/debian/rules
==============================================================================
--- tagcoll/trunk/debian/rules	(original)
+++ tagcoll/trunk/debian/rules	Thu Mar  2 00:22:32 2006
@@ -3,6 +3,7 @@
 include /usr/share/cdbs/1/rules/debhelper.mk
 include /usr/share/cdbs/1/class/autotools.mk
 
+DEB_MAKE_CHECK_TARGET := check
 DEB_CONFIGURE_EXTRA_FLAGS += --disable-shared --with-pic
 
 # Store build information

Modified: tagcoll/trunk/tools/tagcoll.cc
==============================================================================
--- tagcoll/trunk/tools/tagcoll.cc	(original)
+++ tagcoll/trunk/tools/tagcoll.cc	Thu Mar  2 00:22:32 2006
@@ -29,6 +29,11 @@
 
 #include "CommandlineParser.h"
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+
 #include <stdio.h>
 
 #include <stdlib.h>	// getenv
@@ -60,6 +65,14 @@
 using namespace std;
 using namespace Tagcoll;
 
+bool isdir(const std::string& file)
+{
+	struct stat st;
+	if (stat(file.c_str(), &st) == -1)
+		throw SystemException(errno, "trying to stat file " + file);
+	return S_ISDIR(st.st_mode);
+}
+
 void printItems(const set<string>& items, const string& prefix = "")
 {
 	for (set<string>::const_iterator i = items.begin();
@@ -127,6 +140,22 @@
 		StdioParserInput input(stdin, "<stdin>");
 		return TextFormat<string, string>::parsePatch(conv, conv, input);
 	}
+	else if (isdir(file))
+	{
+		PatchList<string, string> patches;
+		DIR* dir = opendir(file.c_str());
+		if (dir == NULL)
+			throw SystemException(errno, "reading directory " + file);
+		while (struct dirent* d = readdir(dir))
+		{
+			if (d->d_name[0] == '.')
+				continue;
+			StdioParserInput input(file + '/' + d->d_name);
+			patches.addPatch(TextFormat<string, string>::parsePatch(conv, conv, input));
+		}
+		closedir(dir);
+		return patches;
+	}
 	else
 	{
 		StdioParserInput input(file);



More information about the Debtags-commits mailing list