www.delorie.com/djgpp/doc/libc/libc_526.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]



#include <fcntl.h>

char * _lfn_gen_short_fname (const char *long_fname, char *short_fname);


This function generates a short (8+3) filename alias for the long filename pointed to by long_fname and puts it into the buffer pointed to by short_fname. It uses the same algorithm that Windows 9x uses, with the exception that the returned short name will never have a numeric tail, because this function doesn't check the directory to see whether the generated short name will collide with any other file in the directory. Note that long_fname must contain only the name part of a file; elements of a full pathname (like : or / are not allowed (they will cause the function to fail). short_fname will be returned upper-cased, since that is how 8+3 filenames are stored in directory entries.

When the LFN API is not supported (see section _use_lfn), the function simply converts up to 12 characters of long_fname to upper-case and returns that. It will do the same if long_fname includes any characters illegal in a filename.

This function returns incorrect results on Windows 2000 and Windows XP due to bugs in the implementation of the DPMI call on those platforms. Do not use this function in those environments.

You might need to call this function if you want to know whether a given filename is valid on MSDOS: if a case-sensitive string comparison function such as strcmp (see section strcmp) returns a 0 when it compares the original long filename with the short one returned by _lfn_gen_short_fname, then the filename is a valid DOS name. (Note that if long_fname is in lower case, it might not compare equal with short_fname because of the case difference.)

Return value

The function returns a pointer to short_fname.




#include <stdio.h>
#include <string.h>
#include <fcntl.h>

int dos_check (char *fname)
  char fshort[13];
  int retval;

  if (stricmp (_lfn_gen_short_fname (fname, fshort), fname) == 0)
    printf ("%s is a valid MSDOS 8+3 filename\n", fname);
    retval = 1;
    printf ("%s will have to be changed for MSDOS\n", fname);
    retval = 0;
  return retval;

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004