/**
  Check if file name has illegal characters.

  @param Name       The filename to check.

  @retval TRUE      The filename is ok.
  @retval FALSE     The filename is not ok.
**/
BOOLEAN
EFIAPI
IsValidFileName (
  IN CONST CHAR16 *Name
  )
{

  UINTN Index;
  UINTN Len;

  //
  // check the length of Name
  //
  for (Len = 0, Index = StrLen (Name) - 1; Index + 1 != 0; Index--, Len++) {
    if (Name[Index] == '\\' || Name[Index] == ':') {
      break;
    }
  }

  if (Len == 0 || Len > 255) {
    return FALSE;
  }
  //
  // check whether any char in Name not appears in valid file name char
  //
  for (Index = 0; Index < StrLen (Name); Index++) {
    if (!IsValidFileNameChar (Name[Index])) {
      return FALSE;
    }
  }

  return TRUE;
}
// ---------------------------------------------------------------------------
// Prepares filename from the displayname of the implementation.
// ---------------------------------------------------------------------------
//
void COMASuplPosTesterModuleCfg::PrepareFileName(TFileName& aOutputFileName, 
							const CImplementationInformation& aImplInfo)
	{
	TInt count = 0;
	TInt displayNameLength = aImplInfo.DisplayName().Length();

	for(count = 0; count < displayNameLength 
					&& count < KMaxFileName - 12; count++)
		{
		if(IsValidFileNameChar(aImplInfo.DisplayName().Ptr() + count))
			{
			aOutputFileName.Append(aImplInfo.DisplayName().Ptr() + count, 1);
			}
		}

	aOutputFileName.Append(_L("_"));
	aOutputFileName.Append(aImplInfo.ImplementationUid().Name().Ptr() + 1
					, aImplInfo.ImplementationUid().Name().Length() - 2);
	//Append file extension
	aOutputFileName.Append(_L(".txt"));
	}