DOS Long File Name CRTL Extension
Although for the most part, the support of LFNs should be transparent when compiling, some changes in headers are necessary.
WCC/WCC386 should allow a new option, perhaps -lfn (to be decided), that predefines a __WATCOM_LFN__
macro to cause header files to allow larger values needed for long filenames. When a program is linked, there should be a WCL/WCL386/WLINK option to specify that LFN modules will be linked in to override the non-LFN clib functions. Perhaps a dos_lfn
system will do the trick.
In addition to modifying older functions, some new functions could make themselves useful, such as a function to convert long filenames to short filenames. This way, the long filenames could be used in functions that only accept short filenames, without much difficulty for the programmer. It should be easy to add LFN support to any program so long as it can be compiled with OpenWatcom, as is the situation with DJGPP. Another useful feature would be to have a global int, such as _lfn_supported
to be set t
o 1 if there is an LFN TSR installed or 0 if there are no LFN TSRs installed.
For now, compatibility with Windows XP, NT (with NTLFN), and 2k is not an issue, but testing should be done exclusively in DOS environments; this includes pure DOS, DOSEMU, DOSBOX (does DOSLFN work in DOSBOX?, apparently not at this time), and possibly Windows 95 / 98, as long as an LFN driver functions correctly on the testing system. The functions should work both with and without an LFN driver installed in memory. After the above systems are found to be stable, work may begin to support other environmen ts, like Windows XP and 2k.
At this point in time the todo list is as followed:
- Submit a patch - Done
- Test really well for bugs with a complete clib - In Progress
- Submit bugfixes if necessary - Done
- Make it more complete if I missed some functions - In Progress (hopefully done)
- Add LFN2SFN function and other helper functions - Done
- Complete documentation - In progress
- Testing in complex programs (such as wcc itself)
Functions that still need LFN support include:
- unknown
The following values should be changed:
NAME_MAX = 12 should be NAME_MAX = 260
_MAX_PATH = 144 should be _MAX_PATH = 260
_MAX_DIR = 130 should be _MAX_DIR = 260
_MAX_FNAME = 9 should be _MAX_FNAME = 260
_MAX_EXT = 5 should be _MAX_EXT = 260
_MAX_NAME = 13 should be _MAX_NAME = 260
Structures find_t
and dirent
need to hold LFN specific data. SFN related DOS calls uses reserved data area (21 bytes) but LFN related doesn't. This data area is used to hold LFN specific data similary then SFN related DOS calls for appropriate data. Therefore no change of find_t
or dirent
structure is required. LFN DOS calls use following __doslfn_dta structure to save necesary LFN data.
typedef struct __doslfn_dta {
unsigned short cr_time;
unsigned short cr_date;
unsigned short ac_time;
unsigned short ac_date;
unsigned long sign;
unsigned short handle;
} __doslfn_dta;
This structure overlaying the standard reserved data area (21 bytes) used by SFN DOS calls. It is used only internally by C run-time library that is not part of public declaration.
The name
field length in find_t
and dirent
structures would be extended to support a full long filename and the same struct would be at the same time compatible with the non-LFN equivalent - to the extent that on DOS without LFN and non-DOS systems the layout of existing fields and size of the structure would be completely unchanged, while on new LFN-enabled DOS builds the structure would have different size and layout but still be source compatible and only require a recompilation to use.
Function | Header | Implementation Status |
---|---|---|
mkdir, _mkdir | direct.h | working |
chdir, _chdir | direct.h | working |
rmdir, _rmdir | direct.h | working |
getcwd, _getdcwd | direct.h | working |
opendir | direct.h | working |
readdir | direct.h | working |
closedir | direct.h | working |
_dos_creat | dos.h | working |
_dos_creatnew | dos.h | working |
_dos_open | dos.h | working |
_dos_findfirst | dos.h | working |
_dos_findnext | dos.h | working |
_dos_getfileattr | dos.h | working |
_dos_setfileattr | dos.h | working |
_dos_findclose | dos.h | working |
access, _access | io.h | working (but not in Win2k, patches welcome) |
chmod. _chmod | io.h | working |
open, _open | io.h | working |
sopen, _sopen | io.h | working |
unlink, _unlink | io.h | working |
remove | io.h | working |
_findfirst | io.h | working but needs further testing |
_findclose | io.h | needs further testing |
_findnext | io.h | not working |
execve, _execve | process.h | working (patch still to be committed) |
spawnve, _spawnve | process.h | working (patch still to be committed) |
stat, _stat | sys/stat.h | working |
lstat. _lstat | sys/stat.h | working |
fopen | stdio.h | working |
rename | stdio.h | working |
- Welcome
- Building
- Open Watcom Documentation
- Notes
- Relicensing effort
- Debugging
- OW tools usage Overview
- OW tools usage with CMake
- OW tools usage with Visual Studio Code
- Open Watcom 1.9 Wiki
OW Development
WGML Development
- WGML
- Augmented Devices
- Binary Device Files
- Common File Blocks
- COP Files
- Device File Blocks
- Device Function Language
- Device Function Notes
- Device Functions
- Directory File Format
- Drawing Boxes
- Driver File Blocks
- File and Directory Names
- Font File Blocks
- Fonts
- GML Tag Notes
- Keyword Statistics
- Macros and User Defined Tags
- Meta Data
- Page Layout Subsystem
- Search Paths
- Sequencing
- System Symbol Notes
- Tabs and Tabbing
- whpcvt Utility interaction