home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / mag&info / msjv7_4.zip / OPEN.ARJ / TRUENAME.C < prev   
Text File  |  1992-07-01  |  1KB  |  58 lines

  1. /*
  2.       Copyright 1991 by David Thielen, All Rights Reserved.
  3.  
  4.       This code example is from a commercial product and has restricted
  5.       rights.  This code, or any code derived from this code may be
  6.       incorporated into any programs with the following restrictions;
  7.       1) It cannot be sold as source code, and 2) It cannot be sold in a
  8.       product which provides this code as an API.
  9. */
  10.  
  11.  
  12. #include "file_io.h"
  13. #include "string.h"
  14.  
  15. // Convert the file name in pFile to the true name (elim append, join, &
  16. // subst) and put it in pTrue.  On an error, will return the passed in
  17. // name.
  18.  
  19. unsigned FileTrueName (BYTE const *pFile,BYTE *pTrue)
  20. {
  21. unsigned uRtn;
  22.  
  23. #ifdef   DEBUG
  24.    if ((! pFile) || (! pTrue) || (! *pFile))
  25.       DebugPrintf ("TrueName (%s(%X), (%X))\n", pFile, pFile, pTrue);
  26.    memset (pTrue, '$', 128);
  27. #endif
  28.  
  29.    // Before DOS 3 - can't do it.
  30.    // Return the passed in name so you have something
  31.    if (DosMajVer < 3)
  32.       {
  33.       strcpy (pTrue, pFile);
  34.       return (-1);
  35.       }
  36.  
  37.    *pTrue = 0;
  38.    _asm
  39.       {
  40.       mov      ax, 6000h
  41.       mov      si, [pFile]
  42.       mov      di, [pTrue]
  43.       push  ds
  44.       pop      es
  45.       int      21h                  // Convert file name
  46.       mov      [uRtn], ax
  47.       jc    dne
  48.       mov      [uRtn], 0
  49. dne:
  50.       }
  51.  
  52.    if (uRtn)
  53.       strcpy (pTrue, pFile);
  54.    return (uRtn);
  55. }
  56.  
  57.  
  58.