Пример #1
0
EFI_STATUS
UtilSetEFIDroidVariable (
  IN CONST CHAR8* Name,
  IN CONST CHAR8* Value
)
{
  EFI_STATUS Status;
  CHAR16     *Name16;

  // convert name to unicode
  Name16 = Ascii2Unicode(Name);
  if (Name16 == NULL)
    return EFI_OUT_OF_RESOURCES;

  // set variable
  Status = gRT->SetVariable (
              Name16,
              &gEFIDroidVariableGuid,
              (EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS),
              Value?AsciiStrSize(Value):0, (VOID*)Value
            );

  // free name
  FreePool(Name16);

  return Status;
}
Пример #2
0
unsigned char TFDrive::rmdir(char *filepath)
{
	unsigned short path_t[256];
	Ascii2Unicode((unsigned char *)filepath,(unsigned short *)path_t,strlen(filepath)*2);
	path_t[strlen(filepath)] = 0x0000;

	return ard_sd_rmdir((char*)path_t);
}
Пример #3
0
LFile TFDrive::open(char *filename,uint8_t mode)
{
	unsigned short path_t[256];

	Ascii2Unicode((unsigned char *)filename,(unsigned short *)path_t,strlen(filename)*2);
	path_t[strlen(filename)] = 0x0000;
	return LFile((void *)path_t,mode);
}
Пример #4
0
void AudioClass::playFile(const char *path){
	int i;
	unsigned short path_t[256];
	if(_st == AUDIO_SD)
	{
		Ascii2Unicode((unsigned char *)path,(unsigned short *)path_t,strlen(path)*2);
		path_t[strlen(path)] = 0x0000;
		i = ard_audio_playfile((wchar_t*)path_t);
		while(i);
	}
}
Пример #5
0
CHAR8*
UtilGetEFIDroidVariable (
  IN CONST CHAR8* Name
)
{
  EFI_STATUS Status;
  UINTN      Size;
  CHAR16     *Name16;
  CHAR8*     ReturnValue;

  ReturnValue = NULL;

  // convert name to unicode
  Name16 = Ascii2Unicode(Name);
  if (Name16 == NULL)
    return NULL;

  // get size of 'EFIDroidErrorStr'
  Size = 0;
  Status = gRT->GetVariable (Name16, &gEFIDroidVariableGuid, NULL, &Size, NULL);
  if (Status == EFI_BUFFER_TOO_SMALL) {
    // allocate memory
    CHAR8* Data = AllocateZeroPool(Size);
    if (Data) {
      // get actual variable value
      Status = gRT->GetVariable (Name16, &gEFIDroidVariableGuid, NULL, &Size, Data);
      if (Status == EFI_SUCCESS) {
        ReturnValue = Data;
      }
      else {
        FreePool(Data);
      }
    }
  }

  // free name
  FreePool(Name16);

  return ReturnValue;
}
Пример #6
0
BOOL CI18n::LoadLanguage(CString strLanguage)
{

	ENTRY_TRACE(_T("CI18n::LoadLanguage(%s)"), strLanguage);

	CString strFilepath;

	strFilepath.Format(_T("%s\\%s.txt"), g_sSettings.GetWorkingDir() + "\\languages", strLanguage);

	CStdioFile fFile;
	CFileException e;
	CString strText	= "";
	sections  sMode = COMMENT;
	
	TRY{

		if(!fFile.Open(strFilepath, CFile::modeRead|CFile::shareDenyWrite|CFile::typeText, &e)){

			LTRACE(_T("Failed to open language file %s"), strFilepath);
			return FALSE;
		}
		fFile.SeekToBegin();
		
		while(fFile.ReadString(strText)){

			strText.TrimLeft();
			strText.TrimRight();
			
			if(strText == _T("START"))      sMode = DIALOG_SEC;
			else if(strText == _T("END"))        sMode = COMMENT;
			else if(strText == _T("INFO_START")) sMode = LANGUAGE_HEADER;
			else if(strText == _T("INFO_END"))   sMode = COMMENT;
			
			if(!strText.IsEmpty() && (strText.Left(1) == _T("#"))){


				switch(sMode){

				case DIALOG_SEC:
					m_viItems.push_back(GetI18nItem(Ascii2Unicode(strText)));
					break;
				case LANGUAGE_HEADER:

					if(strText.Left(10) == _T("#LANGUAGE#")){

						m_strLanguageName = strText.Mid(11, strText.GetLength() - 11);
						m_strLanguageName.TrimLeft();
						m_strLanguageName.TrimRight();
						m_strLanguageName = m_strLanguageName.Mid(1, m_strLanguageName.GetLength() - 2);
					}
					else if(strText.Left(10) == _T("#CODEPAGE#")){

						m_strCodepage = strText.Mid(11, strText.GetLength() - 11);
						m_strCodepage.TrimLeft();
						m_strCodepage.TrimRight();						
						m_strCodepage = m_strCodepage.Mid(1, m_strCodepage.GetLength() - 2);
						m_dwCodePageID = _ttoi(m_strCodepage);
						
					}
					else if(strText.Left(8) == _T("#AUTHOR#")){

						m_strAuthor = strText.Mid(8, strText.GetLength() - 8);
						m_strAuthor.TrimLeft();
						m_strAuthor.TrimRight();						
						m_strAuthor = m_strAuthor.Mid(1, m_strAuthor.GetLength() - 2);
					}
					break;
				}
			}
		}

		fFile.Close();
	}
	CATCH( CFileException, e )
	{

	   #ifdef _DEBUG
		  afxDump << "File could not be opened " << e->m_cause << "\n";
	   #endif

	   m_bLoaded = FALSE;
	   m_strLoadedLang = "";
	}