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

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

_use_lfn

Syntax

 
#include <fcntl.h>
 
char _use_lfn(const char *path);

Description

The _use_lfn function returns a nonzero value if the low level libc routines will use the Long File Name (LFN) functions provided with Windows 9x (and other advanced filesystems), when accessing files and directories on the same filesystem as path. path may be any legal pathname; however, the function only needs the name of the root directory on the particular drive in question. If path is a NULL pointer, the function assumes that all the filesystems support (or do not support) LFN in the same manner, and returns the info pertinent to the last filesystem that was queried; this usually makes the call faster. Note that on Windows 95 you don't need to distinguish between different drives: they all support LFN API. If path does not specify the drive explicitly, the current drive is used.

The header `fcntl.h' defines a macro _USE_LFN; applications should use this macro instead of calling _use_lfn directly. That is so this routine could be replaced with one which always returns 0 to disable using long file names. Calling _USE_LFN also makes the code more portable to other operating systems, where the macro can be redefined to whatever is appropriate for that environment (e.g., it should be a constant 1 on Unix systems and constant 0 for environments that don't support LFN API, like some other MSDOS compilers). Currently, _USE_LFN assumes that LFN API does not depend on a drive.

Long file names can also be disabled by setting the flag _CRT0_FLAG_NO_LFN in _crt0_startup_flags for an image which should not allow use of long file names. Long names can be suppressed at runtime on a global basis by setting the environment variable LFN to N, i.e. `SET LFN=N'. This might be needed if a distribution expected the truncation of long file names to 8.3 format to work. For example, if a C source routine included the file exception.h (9 letters) and the file was unzipped as exceptio.h, then GCC would not find the file unless you set `LFN=n'. The environment variable can be set in the `DJGPP.ENV' file to always disable LFN support on any system, or can be set in the DOS environment for a short term (single project) basis. If you dual boot a system between Windows 95 and DOS, you probably should set `LFN=n' in your `DJGPP.ENV' file, since long file names would not be visible under DOS, and working with the short names under DOS will damage the long names when returning to Windows 95.

Return Value

If LFN APIs are supported and should be used, it returns 1, else 0.

Note that if the _CRT0_FLAG_NO_LFN bit is set, or LFN is set to N or n in the environment, both _use_lfn and _USE_LFN will always return 0 without querying the filesystem. You can reset the _CRT0_FLAG_NO_LFN bit at runtime to force filesystem to be queried.

Portability

ANSI/ISO C No
POSIX No

Example

 
#include <fcntl.h>
#include <sys/stat.h>

  int fd = creat (_USE_LFN ? "MyCurrentJobFile.Text" : "currjob.txt",
                  S_IRUSR | S_IWUSR);


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

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004