const char *save_spec;
char *ret_spec;
int retval = -1;
- int efs_hack = 0;
+ char efs_hack = 0;
+ char already_fileified = 0;
dSAVEDERRNO;
if (!fspec) {
else
retval = lstat(fspec, &statbufp->crtl_stat);
- save_spec = fspec;
+ if (!retval) {
+ save_spec = fspec;
+ }
+ else {
+ /* In the odd case where we have write but not read access
+ * to a directory, stat('foo.DIR') works but stat('foo') doesn't.
+ */
+ fileified = PerlMem_malloc(VMS_MAXRSS);
+ if (fileified == NULL)
+ _ckvmssts_noperl(SS$_INSFMEM);
+
+ ret_spec = int_fileify_dirspec(fspec, fileified, NULL);
+ if (ret_spec != NULL) {
+ if (lstat_flag == 0)
+ retval = stat(fileified, &statbufp->crtl_stat);
+ else
+ retval = lstat(fileified, &statbufp->crtl_stat);
+ save_spec = fileified;
+ already_fileified = 1;
+ }
+ }
+
if (retval && vms_bug_stat_filename) {
temp_fspec = PerlMem_malloc(VMS_MAXRSS);
/* If we've got a directory, save a fileified, expanded version of it
* in st_devnam. If not a directory, just an expanded version.
*/
- if (S_ISDIR(statbufp->st_mode)) {
+ if (S_ISDIR(statbufp->st_mode) && !already_fileified) {
fileified = PerlMem_malloc(VMS_MAXRSS);
if (fileified == NULL)
_ckvmssts_noperl(SS$_INSFMEM);