[patch@34896] vms readdir() fixes for UNIX/EFS mode

[email protected] ("John E. Malmberg")
Newsgroups perl.perl5.porters,perl.vmsperl
Message-ID <[email protected]>
Readdir() on VMS, when opening a directory with a UNIX file 
specification, should return all the files in UNIX format.

This includes dropping the ".DIR" from the directory specifications.

Because traditionally Perl has not done this, this fix will only be done 
when the DECC$EFS_CHARSET feature is enabled.


Next on the fix list for Unix compatibility mode, <*> is always 
returning specifications in VMS format instead of UNIX format when 
DECC$FILENAME_UNIX_REPORT is active.

Regards,
-John
vms_c_readir.gdiff (text/plain, 1.3 KB)
--- /rsync_root/perl/vms/vms.c	Mon Nov 10 06:51:29 2008
+++ vms/vms.c	Sat Nov 22 10:46:34 2008
@@ -9631,11 +9631,32 @@
 	&vs_spec,
 	&vs_len);
 
-    /* Drop NULL extensions on UNIX file specification */
-    if ((dd->flags & PERL_VMSDIR_M_UNIXSPECS &&
-	(e_len == 1) && decc_readdir_dropdotnotype)) {
-	e_len = 0;
-	e_spec[0] = '\0';
+    if (dd->flags & PERL_VMSDIR_M_UNIXSPECS) {
+
+        /* In Unix report mode, remove the ".dir;1" from the name */
+        /* if it is a real directory. */
+        if (decc_filename_unix_report || decc_efs_charset) {
+            if ((e_len == 4) && (vs_len == 2) && (vs_spec[1] == '1')) {
+                if ((toupper(e_spec[1]) == 'D') &&
+                    (toupper(e_spec[2]) == 'I') &&
+                    (toupper(e_spec[3]) == 'R')) {
+                    Stat_t statbuf;
+                    int ret_sts;
+
+                    ret_sts = stat(buff, (stat_t *)&statbuf);
+                    if ((ret_sts == 0) && S_ISDIR(statbuf.st_mode)) {
+                        e_len = 0;
+                        e_spec[0] = 0;
+                    }
+                }
+            }
+        }
+
+        /* Drop NULL extensions on UNIX file specification */
+	if ((e_len == 1) && decc_readdir_dropdotnotype) {
+	    e_len = 0;
+	    e_spec[0] = '\0';
+        }
     }
 
     strncpy(dd->entry.d_name, n_spec, n_len + e_len);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.