void __fastcall TfrmMain::WMDropFiles(TWMDropFiles& Message)
{
  int Count = DragQueryFile(reinterpret_cast<void*>(Message.Drop), 0xFFFFFFFF, NULL, 0);
  try
  {
    char FileBuf[MAX_PATH+1];
    if (Count > 0)
    {
      TStringList* FileList = new TStringList();
      try
      {
        for (int i = 0; i < Count; i++)
        {
          DragQueryFile(reinterpret_cast<void*>(Message.Drop), i, FileBuf, sizeof(FileBuf));
          FileList->Add(FileBuf);
        }
        FileList->Sort();
        reSource->Lines->BeginUpdate();
        try
        {
          reSource->Lines->Clear();
          for (int i = 0; i < FileList->Count; i++)
            reSource->Lines->Add(StringFromFile(FileList->Strings[i]));
        }
        __finally
        {
          reSource->Lines->EndUpdate();
        }
      }
      __finally
      {
        delete FileList;
      }
    }
  } __finally {
Beispiel #2
0
StrongRef<Shader> Shader::CreateFromFile( Context* context, ShaderType type, const char* file )
{
	Shader* obj = new Shader(context, type);

	obj->m_File = file;

	std::string source = StringFromFile(file);
	if(source.empty())
    {
        LogError("Can't load shader source '%s'.", file);
		return NULL;
    }

	const char* shaderSource = source.c_str();
	int shaderLength = source.length();
	glShaderSource(obj->m_Handle, 1, &shaderSource, &shaderLength);

	glCompileShader(obj->m_Handle);


	GLint state;
	glGetShaderiv(obj->m_Handle, GL_COMPILE_STATUS, &state);
	ShowShaderLog(obj->m_Handle);
	if(state)
    {
		Log("Compiled shader object '%s' successfully", file);
    }
    else
    {
        LogError("Can't compile shader object '%s'", file);
		return NULL;
    }

	return StrongRef<Shader>(obj);
}
Beispiel #3
0
void __fastcall TfrmSpeedTest::Test(bool Decode)
{
  WaitCursor();
  for (int i = 0; i < memFiles->Lines->Count; i++)
    if (FileExists(memFiles->Lines->Strings[i]))
    {
      __int64 FStringLength;
      AnsiString S = StringFromFile(memFiles->Lines->Strings[i], FStringLength);
      Cardinal FStartTime = GetTickCount();
      if (Decode)
        SimpleXMLDecode(S, false);
      else
        SimpleXMLEncode(S);
      AddInfo(memFiles->Lines->Strings[i], Decode, FStringLength, GetTickCount() - FStartTime, sgResults->Cells[0][1] != "");
    }
}
Strings ReadStrings(FILE *f) {
	Strings strings = {};

	int rows;
	size_t bytes = fread(&rows, sizeof(rows), 1, f);
	if (bytes == 0) goto ERROR;

	strings = NewStringsTable(rows);
	int i;
	for (i = 0; i < rows; i++) {
		char *text = StringFromFile(f);
		if (text == NULL) goto ERROR;

		InsertString(strings, text);
		free(text);
	}
	
	return strings;

ERROR:
	if (strings.table != NULL) LFK_FreeTable(strings.table);

	return (Strings){};
}