Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- libc - <b>_lfn_gen_short_fname</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_lfn_gen_short_fname
====================

Syntax
------

     #include <fcntl.h>
     
     char _lfn_gen_short_fname (const char *long_fname, char *short_fname);

Description
-----------

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 (_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.

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' (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.

Example
-------

     #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;
       }
       else
       {
         printf ("%s will have to be changed for MSDOS\n", fname);
         retval = 0;
       }
       return retval;
     }


See Also: _use_lfn strcmp

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson