void Shorten_File_Name (char *string, int x)
// x = the target file length. If the extracted file name
// is large enough it will possibly exceed the target length.
// Windows filenames can get quite large and you may want to
// allow the ability to shorten that if exceeds a certain length
// input - C:\Program Files\Borland\CBuilder5\Examples\Apps\Cursors\readme.txt
// output - C:\Progr...\readme.txt
{
int length = strlen (string);
int a;
int b;
if (length > x)
{
char *buff1 = new char [60];
char *buff2 = new char [256];
strcpy (buff1, ExtractFileName(string).c_str ());
a = x - strlen (buff1);
if (a > 3) // if there is enough room.
{
for (b = 0; b < (a - 2); b++)
buff2 [b] = string [b];
buff2[b] = NULL;
}
else // this just appends the file name to the drive name
// with the "..." in the middle.
{
for (b = 0; b < 3; b++)
buff2 [b] = string [b];
buff2[b] = NULL;
}
strcat (buff2, "...\\");
strcat (buff2, buff1);
strcpy (string, buff2);
delete buff1;
delete buff2;
}
}