www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000173

When Created: 08/28/1997 06:06:03
Against DJGPP version: 2.01
By whom: eliz@is.elta.co.il
Abstract: rename directory and _truename fail on Windows 95 with LFN=y
Calling the library function `rename' to rename a directory will fail when
long filenames are supported.

The problem is actually in the `_truename' library function which fails
under LFN for non-existing files, whereas it succeeds when long filenames
are NOT supported.  This is actually a feature of the LFN function called
by `_truename' internally.

Solution added: 08/28/1997 06:07:37
By whom: eliz@is.elta.co.il
The following patch to `_truename' makes it and `rename' work:

*** src/libc/dos/dos/truename.c~1       Sun Nov  3 12:39:28 1996
--- src/libc/dos/dos/truename.c Tue Aug 26 14:48:52 1997
*************** _truename(const char *file, char *buf)
*** 53,58 ****
--- 53,59 ----
    unsigned short  our_mem_selector = _my_ds();
    int             e                = errno;
    unsigned      use_lfn          = _USE_LFN;
+   int           first_time       = 1;

    char true_name[MAX_TRUE_NAME];
    char file_name[MAX_TRUE_NAME], *name_start = file_name, *name_end;
*************** _truename(const char *file, char *buf)
*** 111,116 ****
--- 112,118 ----
    /* According to Ralph Brown's Interrupt List, can't make the input
       and output buffers be the same, because it doesn't work for early
       versions of DR-DOS.  */
+  lfn_retry:
    regs.x.ds = regs.x.es = __tb_segment;
    regs.x.si = __tb_offset;
    regs.x.di = __tb_offset + MAX_TRUE_NAME;
*************** _truename(const char *file, char *buf)
*** 122,127 ****
--- 124,138 ----

    if (regs.x.flags & 1)
      {
+       if (use_lfn && first_time)
+       {
+         /* If the file doesn't exist, 217160/CX=2 fails.  Try again
+            with CX=0, so that this time it won't validate the path.  */
+         first_time = 0;
+         regs.x.ax = 0x7160;
+         regs.x.cx = 0;
+         goto lfn_retry;
+       }
        errno = __doserr_to_errno(regs.x.ax);
        return (char *)0;
      }

Fixed in version on 04/12/1999 11:00:15
By whom: eliz@is.elta.co.il



  webmaster     delorie software   privacy  
  Copyright © 2010   by DJ Delorie     Updated Jul 2010