VOGONS


Lowercase file names?

Topic actions

First post, by hmn

User metadata
Rank Newbie
Rank
Newbie

Is there any way to control the "case" of file names in the host filesystem for files created by applications running in Dosbox?

Dosbox currently creates uppercase file names here, but I'd like it to create lowercase file names instead.

Reply 1 of 8, by hmn

User metadata
Rank Newbie
Rank
Newbie

I have come up this this hack, which seems to do the trick for me so far (obviously not suited for submission in this form).

diff --git a/trunk/src/dos/drive_cache.cpp b/trunk/src/dos/drive_cache.cpp
index 633138e9..8b0d8e1a 100644
--- a/trunk/src/dos/drive_cache.cpp
+++ b/trunk/src/dos/drive_cache.cpp
@@ -502,9 +502,19 @@ static Bits wine_hash_short_file_name( char* name, char* buffer )
}
#endif

+static void to_lower_case(char *s)
+{
+ while (*s) {
+ *s++ = tolower(*s);
+ }
+}
+
Bits DOS_Drive_Cache::GetLongName(CFileInfo* curDir, char* shortName) {
std::vector<CFileInfo*>::size_type filelist_size = curDir->fileList.size();
- if (GCC_UNLIKELY(filelist_size<=0)) return -1;
+ if (GCC_UNLIKELY(filelist_size<=0)) {
+ to_lower_case(shortName);
+ return -1;
+ }

// Remove dot, if no extension...
RemoveTrailingDot(shortName);
@@ -523,7 +533,10 @@ Bits DOS_Drive_Cache::GetLongName(CFileInfo* curDir, char* shortName) {
};
}
#ifdef WINE_DRIVE_SUPPORT
- if (strlen(shortName) < 8 || shortName[4] != '~' || shortName[5] == '.' || shortName[6] == '.' || shortName[7] == '.') return -1; // not available
+ if (strlen(shortName) < 8 || shortName[4] != '~' || shortName[5] == '.' || shortName[6] == '.' || shortName[7] == '.') {
+ to_lower_case(shortName);
+ return -1; // not available
+ }
// else it's most likely a Wine style short name ABCD~###, # = not dot (length at least 8)
// The above test is rather strict as the following loop can be really slow if filelist_size is large.
char buff[CROSS_LEN];
@@ -538,6 +551,7 @@ Bits DOS_Drive_Cache::GetLongName(CFileInfo* curDir, char* shortName) {
}
#endif
// not available
+ to_lower_case(shortName);
return -1;
}

Reply 2 of 8, by rmay635703

User metadata
Rank Oldbie
Rank
Oldbie
hmn wrote on 2025-08-30, 13:52:

Is there any way to control the "case" of file names in the host filesystem for files created by applications running in Dosbox?

Dosbox currently creates uppercase file names here, but I'd like it to create lowercase file names instead.

I remember lowercase file names / extensions breaking certain apps back in the Windows 95/98 era.

Is there some special reason you want to do this?

Reply 3 of 8, by hmn

User metadata
Rank Newbie
Rank
Newbie

I am doing some development with Pacific C under Dosbox, and for portability reasons, I want the source file names to be lowercase. I tried renaming the source files created in the host file system (which works at first), but then the Pacific IDE (or compiler?) regularly seems to rename/re-create files that are edited, which then makes them uppercase in the host file system again.

Reply 4 of 8, by Harry Potter

User metadata
Rank Oldbie
Rank
Oldbie

I think DOSBox renames the files as upper-case because DOS uses all upper case letters in its filenames.

Joseph Rose, a.k.a. Harry Potter
Working magic in the computer community

Reply 5 of 8, by hmn

User metadata
Rank Newbie
Rank
Newbie

Dosbox does not rename anything, and it works just fine with lower/mixed-cased file names in the host file system. Files newly created by applications running under Dosbox are created in upper case on the host file system, which is not a problem generally, but in my case the application re-creates the files, thus changing the file name in the host file name (unless it was already uppercase), which is what I am trying to work around.

Reply 6 of 8, by Harry Potter

User metadata
Rank Oldbie
Rank
Oldbie

Oh. At least I tried. 🙁

Joseph Rose, a.k.a. Harry Potter
Working magic in the computer community

Reply 7 of 8, by hmn

User metadata
Rank Newbie
Rank
Newbie

No worries 😀

There can be no general solution here because DOS does not retain case information. The application basically does "rename foobar.c to FOOBAR.BAK, newly create FOOBAR.C". While my workaround prevents "foobar.c" from being re-created as "FOOBAR.C", it would also cause e.g. "FooBar.c" to be re-created as "foobar.c", again changing the file name in the (case-sensitive) host file system.

Reply 8 of 8, by Azarien

User metadata
Rank Oldbie
Rank
Oldbie
hmn wrote on Yesterday, 19:27:

There can be no general solution here because DOS does not retain case information.

There is case-preserving and case-sensitivity. DOS is not case-preserving. Windows is case-preserving but case-insensitive. Case preserving on FAT partitions is achieved with LFN (long filenames) mechanism, even if the name would otherwise fit in the 8.3 scheme.
With LFN support in DOS (e.g. DOSLFN or a DOSBox fork that supports long filenames) case preserving may work in DOS too.