summary refs log tree commit diff stats
path: root/plugins/perl/perl.c
diff options
context:
space:
mode:
authorBerke Viktor <bviktor@hexchat.org>2012-07-13 20:07:47 +0200
committerBerke Viktor <bviktor@hexchat.org>2012-07-13 20:07:47 +0200
commit683a60abff456e762b3317b9d5d82b346f7d3cd2 (patch)
treeb2728482fd43914a9d289f7163225ec55168233a /plugins/perl/perl.c
parent6fd3a18fcfd874ba90c7cb5fdad43e5c0e94a204 (diff)
Update XChat to r1511
Diffstat (limited to 'plugins/perl/perl.c')
-rw-r--r--plugins/perl/perl.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c
index b07aa651..68789828 100644
--- a/plugins/perl/perl.c
+++ b/plugins/perl/perl.c
@@ -72,6 +72,43 @@ thread_mbox (char *str)
 
 /* leave this before XSUB.h, to avoid readdir() being redefined */
 
+#ifdef WIN32
+static void
+perl_auto_load_from_path (const char *path)
+{
+	WIN32_FIND_DATA find_data;
+	HANDLE find_handle;
+	char *search_path;
+	int path_len = strlen (path);
+
+	/* +6 for \*.pl and \0 */
+	search_path = malloc(path_len + 6);
+	sprintf (search_path, "%s\\*.pl", path);
+
+	find_handle = FindFirstFile (search_path, &find_data);
+
+	if (find_handle != INVALID_HANDLE_VALUE)
+	{
+		do
+		{
+			if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
+				||find_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
+			{
+				char *full_path =
+					malloc (path_len + strlen (find_data.cFileName) + 2);
+				sprintf (full_path, "%s\\%s", path, find_data.cFileName);
+
+				perl_load_file (full_path);
+				free (full_path);
+			}
+		}
+		while (FindNextFile (find_handle, &find_data) != 0);
+		FindClose (find_handle);
+	}
+
+	free (search_path);
+}
+#else
 static void
 perl_auto_load_from_path (const char *path)
 {
@@ -92,6 +129,7 @@ perl_auto_load_from_path (const char *path)
 		closedir (dir);
 	}
 }
+#endif
 
 static int
 perl_auto_load (void *unused)