[svn:parrot] r44885 - trunk/src/pmc

jonathan at svn.parrot.org jonathan at svn.parrot.org
Thu Mar 11 22:28:14 UTC 2010


Author: jonathan
Date: Thu Mar 11 22:28:12 2010
New Revision: 44885
URL: https://trac.parrot.org/parrot/changeset/44885

Log:
[os.pmc] Correct an oversight in the Win32 implementation of readdir - should handle being passed directory name that already has a trailing slash.

Modified:
   trunk/src/pmc/os.pmc

Modified: trunk/src/pmc/os.pmc
==============================================================================
--- trunk/src/pmc/os.pmc	Thu Mar 11 20:43:49 2010	(r44884)
+++ trunk/src/pmc/os.pmc	Thu Mar 11 22:28:12 2010	(r44885)
@@ -504,8 +504,11 @@
         HANDLE hFind = INVALID_HANDLE_VALUE;
 
         /* Add \* to the directory name and start search. */
+        STRING *last_char = Parrot_str_substr(interp, path, Parrot_str_length(interp, path) - 1, 1, NULL, 0);
+        int trailing_slash = Parrot_str_equal(interp, last_char, string_from_literal(interp, "\\")) ||
+                             Parrot_str_equal(interp, last_char, string_from_literal(interp, "/"));
         cpath = Parrot_str_to_cstring(interp, Parrot_str_concat(interp,
-                path, string_from_literal(interp, "\\*"), 0));
+                path, string_from_literal(interp, trailing_slash ? "*" : "\\*"), 0));
         hFind = FindFirstFile(cpath, &file_find_data);
         Parrot_str_free_cstring(cpath);
         if (hFind == INVALID_HANDLE_VALUE)


More information about the parrot-commits mailing list