/*	======================================================================
 *	Case conversion of files and directories names. I found this tool
 *	REALLY useful because I need to access files on VFAT and NTFS
 *	volumes from Linux.
 */
#include <../source/TAL/objbase.h>
/*
 *	We use internal filesystem stuff; therefore, LibV must be linked
 *	statically (executable size in case of VC-6 is about 28 kb).
 */
#include <../source/vfs/fsbase.h>

/*
 *	This procedure converts name of object to the down case.
 */
void	V_CALL
lowercase(char *name)
{
	int i;
	char lower[_MAX_PATH];
#ifndef	__UNIX__
	/* Get original name */
	char os_name[_MAX_PATH];
	vfsUnix2Native(os_name,name);
#else
	char *os_name=name;
#endif
	/* Convert name to the down case */
	for(i=0;os_name[i];i++)
		lower[i]=(char)tolower(os_name[i]);
	lower[i]=0;
	printf("'%s' --> '%s'\n",os_name,lower);
	/* Execute C RTL rename() to rename object */
	rename(os_name,lower);
}

int main(void)
{
	puts("Converting all names to the down case, starting from current directory.");
	/*
	 *	Spawn recurcive enumeration of objects passing
	 *	all names to the case conversion procedure.
	 */
	lfsEnumFiles(lowercase,lowercase,true);
	return 0;
}
