Case-Sensitivity of Filenames, PFXplus, and Unix

Introduction | Stop shouting | I never met a lowercase letter I didn't like | INI item reduces case-senstivity problems | The dirty details of using iFileCasMode | dos_xcopy file

Probably also of interest to those using Windows 95 or Windows/NT

Gary Schmidt – UNIX Guru – Powerflex Corporation

A version of this article was originally published in POWERlines Volume 5, No. 5.

One of the potential problems facing those who wish to move products developed in PFXplus under MS-DOS to the Unix environment is that filenames on Unix systems are case-sensitive. This is not a great problem for developers who type in lowercase only, but can be for those who use UPPERCASE continuously.

Having teethed on Unix systems, and also having spent (too much) time in the publishing industry, I have DEVELOPED A STRONG DISLIKE FOR BEING SHOUTED AT IN TYPE. From my particular ivory tower, uppercase is reserved strictly for grabbing the attention of the reader, and has no place in general text, particularly file names, except of course where the name is intended to leap out at the reader.

Stop Shouting

This is why in many Unix directories you will find a file "Readme" or "README", as it will appear near the start of the directory listing, and stands out from all the "xyz.h" and "def.c" files in the directory. If it is absolutely required that the file be first in the directory listing, it is often named "AAREADME", for the same reasons that lead people to purchase advertisements in telephone directories under the name "AAAAAAAAFirst Co." to ensure that they are first in the listing.

The primary requirement when moving a PFXplus application from a case-insensitive environment to one where case is significant is to remember which way the default case goes. In PFXplus for Unix, the default case for everything is lower case, and all default file names and file extensions are stored internally in lower case.

I Never Met a Lowercase Letter I Didn't Like

When programming portably in PFXplus (or any other language) the first general rule of thumb could be simply stated as "turn off CapsLock". Very few systems that are case-insensitive or single-case cannot handle lowercase file names or paths, but as most case-sensitive systems tend to be populated with lowercase names, life is easier if the habit of entering filenames in lowercase is developed early on.

The next problem is transferring all the files needed from the MS-DOS computer to the Unix computer.

If the machines are on an Ethernet LAN, this is usually trivial. One way is to use TCP/IP software, available as shareware/freeware or as a commercial product for MS/PC-DOS systems, and often supplied as standard with Unix systems.

If there is a serial connection between the machines, again it is trivial if time consuming using kermit, zmodem, or a commercial file transfer package.

If necessary, the move can be done using floppy disks, provided the Unix machine can read MS/PC-DOS format disks. Since most do not support wildcard copying from a floppy disk, I wrote a shell script for use on SCO-type Unix systems. It is called dos_xcopy, and will copy the contents of directory on a MS/PC-DOS disk into a directory on a Unix machine. See the listing at the end of this article.

INI Item Reduces Case-Sensitivity Problems When Going to Unix

To help ease the transition from the case-insensitive world of MS/PC-DOS, we have added a configuration item to the PFX.INI file, iFileCaseMode. This option, when activated, causes filenames and paths to be forced to lower case just before the file is physically opened.

This does not make PFXplus for Unix case-insensitive. Instead it forces PFXplus to run in a single-case mode, using just lower case. It effectively prevents the programmer and user from accessing any mixed-case or uppercase files. Be aware that this option will only open files with lower case names. It will not for example open the file "ChainMe.ptc", but it will open "chainme.ptc".

It is important to note that currently this case-changing is done according to the standard 'c' locale rules for the default locale, that is, using the standard 7-bit ASCII rules for case conversion, not according to the case tables used by PFXplus, so people who like filenames of the type möösböök.txt may get unexpected behaviour. This may change if requested by a large enough group of users or developers who are actively using the feature.

The Dirty Details of Using iFileCaseMode

The INI file item iFileCaseMode forces all paths and filenames to lowercase just before they are accessed. Currently the effects of the values are as follows.
0 Do nothing. Case is preserved and will result in case-sensitivity on systems where it is observed.
1 Paths/filenames are lower-cased for copyfile, open, direct_input, direct_output, chain, append_output, erasefile and renamefile.
2 Paths/filenames are lower-cased for directory, and the direct_input dir: driver, as well as for commands mentioned for the value 1.

Note that the change is only on the paths specified. A directory of "ABC", where "abc" is a directory and contains the file "xYz" will still return the file "xYz", although it is not accessible by PFXplus. Note also that directory "ABC/X*" will also return the file "xYz".

Note that INI files are excluded, and are still processed in a case-sensitive manner.

The dos_xcopy File


#! /bin/sh
#
# Copies an entire directory of files from a DOS disk to the
# current directory, lower-casing the file names as we go.
#
# written for SCO UNIX, but should be easy to port to other
# UNIX variants
# 
# Usage:
#	dos_xcopy DOS_DISK:[directory]
#

dosdev=$1

echo "This copies a DOS disk of files from disk ${dosdev}"
dosls ${dosdev} | while read afile
do
	f1=`echo $afile | tr '[A-Z]' '[a-z]'`
	echo "Copying $f1"
	doscp ${dosdev}/$f1 .
done
exit

Back to FAQ Page