Exemplo n.º 1
0
INT32 FreeHandEPSFilter::EPSHeaderIsOk(ADDR pFileHeader, UINT32 HeaderSize)
{
	// Check the first line in EPS file
	if (strncmp((char *) pFileHeader, "%!PS-Adobe", 10) != 0)
	{
		// Incorrect version of EPS header line - we don't want this
		return 0;
	}

	// !PS-Adobe line is ok - check creator line...
	TCHAR *Buffer;
	CCMemTextFile HeaderFile((char *)pFileHeader, HeaderSize);
	if(HeaderFile.IsMemFileInited() == FALSE || HeaderFile.InitLexer() == FALSE)
	{
		HeaderFile.close();
		return 0;
	}


	BOOL HaveCreatorString = FALSE;
	
	UINT32 Lines = 0;
	while ((Lines < 20) && !HeaderFile.eof())
	{
		HeaderFile.GetLineToken();
		Buffer = (TCHAR *)HeaderFile.GetTokenBuf();
		ERROR2IF(Buffer == 0, 0, "Returned buffer from lex file == 0");
		Lines++;

		// Return TRUE if this file was created by Illustrator, or has been exported in 
		// Illustrator format.
		if (camStrncmp( (const TCHAR *)Buffer, _T("%%Creator: "), 11) == 0 && 
			camStrstr( (const TCHAR*)Buffer, _T("FreeHand")) != 0)
		{
			// found a plausible creator string - but it could be any version
			// (3.0 for the Mac gives it's version number here, but the PC one doesn't)
			HaveCreatorString = TRUE;
		}

		if (camStrncmp(Buffer, _T("%%DocumentProcSets: FreeHand_header 3 "), 38) == 0 && HaveCreatorString)
		{
			// I'll have that then.
			HeaderFile.close();
			return 10;
		}

		// If we find the compression token then stop the search as we don't want to start
		// looking in the compressed data!
		if (camStrncmp(Buffer, _T("%%Compression:"), 14)==0)
			break;
	}

	HeaderFile.close();
	
	return 0;
}
Exemplo n.º 2
0
void
BoxLib::WriteMultiLevelPlotfile (const std::string& plotfilename, int nlevels,
				 const Array<const MultiFab*>& mf,
				 const Array<std::string>& varnames,
				 const Array<Geometry>& geom, Real time, const Array<int>& level_steps,
				 const Array<IntVect>& ref_ratio)
{
    BL_PROFILE("WriteMultiLevelPlotfile()");

    BL_ASSERT(nlevels <= mf.size());
    BL_ASSERT(nlevels <= geom.size());
    BL_ASSERT(nlevels <= ref_ratio.size()+1);
    BL_ASSERT(nlevels <= level_steps.size());
    BL_ASSERT(mf[0]->nComp() == varnames.size());

    int finest_level = nlevels-1;

    //
    // Only let 64 CPUs be writing at any one time.
    //
    int saveNFiles(VisMF::GetNOutFiles());
    VisMF::SetNOutFiles(64);

    const std::string versionName("HyperCLaw-V1.1");
    const std::string levelPrefix("Level_");
    const std::string mfPrefix("Cell");

    bool callBarrier(true);
    BoxLib::PreBuildDirectorHierarchy(plotfilename, levelPrefix, nlevels, callBarrier);

    if (ParallelDescriptor::IOProcessor()) {
      std::string HeaderFileName(plotfilename + "/Header");
      std::ofstream HeaderFile(HeaderFileName.c_str(), std::ofstream::out   |
	                                               std::ofstream::trunc |
						       std::ofstream::binary);
      if( ! HeaderFile.good()) {
        BoxLib::FileOpenFailed(HeaderFileName);
      }

      Array<BoxArray> boxArrays(nlevels);
      for(int level(0); level < boxArrays.size(); ++level) {
	boxArrays[level] = mf[level]->boxArray();
      }

      BoxLib::WriteGenericPlotfileHeader(HeaderFile, nlevels, boxArrays, varnames,
                                         geom, time, level_steps, ref_ratio);
    }


    for (int level = 0; level <= finest_level; ++level)
    {
	VisMF::Write(*mf[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix));
    }

    VisMF::SetNOutFiles(saveNFiles);
}
Exemplo n.º 3
0
void ClassBuffer::Search (const char* path) {
    struct stat filestats;

    if (IsADirectory(path, filestats)) {
        if (_recursive) {
            SearchDirs(path);
        } else {
            SearchDir(path);
        }

    } else if (HeaderFile(path) || (_CPlusPlusFiles && CPlusPlusFile(path))) {
        SearchFile(path, filestats);
    }
}
Exemplo n.º 4
0
void StateManager::CreateVertexShader(CONST DWORD* pFunction, HANDLE Shader)
{
    VShaderMap::iterator Iterator = VShaders.find(Shader);
    if(Iterator == VShaders.end())
    {
        VShader *NewShader = new VShader(pFunction, Shader);
        Assert(NewShader != NULL, "Out of memory in StateManager::CreateVertexShader");

        if(CaptureAllShaders && !VertexShaderSimulator.ContainsHash(NewShader->Hash()))
        {
            String AssemblyFilename = g_Context->Parameters.ShaderCaptureDirectory + String("VShader") + String::ZeroPad(String(NewShader->Hash()), 10) + ".txt";
            String SourceFilename   = g_Context->Parameters.ShaderCaptureDirectory + String("VShader") + String::ZeroPad(String(NewShader->Hash()), 10) + ".cpp";
            String HeaderFilename   = g_Context->Parameters.ShaderCaptureDirectory + String("VShader") + String::ZeroPad(String(NewShader->Hash()), 10) + ".h";
            ofstream AssemblyFile(AssemblyFilename.CString());
            NewShader->OutputDisassembly(AssemblyFile);
            if(g_Context->Parameters.OutputCSource)
            {
                ofstream SourceFile(SourceFilename.CString());
                ofstream HeaderFile(HeaderFilename.CString());
                NewShader->OutputCSource(SourceFile, HeaderFile);
            }
        }
        /*g_Context->Files.ShaderInfo << String::ZeroPad(String(NewShader->Hash()), 10) << '\t' << NewShader->Instructions.Length() << '\t';
        Vector<UINT> InstructionCounts;
        NewShader->ComputeShaderInstructionCounts(InstructionCounts);
        for(UINT InstructionIndex = 0; InstructionIndex < InstructionCounts.Length(); InstructionIndex++)
        {
            g_Context->Files.ShaderInfo << InstructionCounts[InstructionIndex];
            if(InstructionIndex != InstructionCounts.Length() - 1)
            {
                 g_Context->Files.ShaderInfo << '\t';
            }
        }
        g_Context->Files.ShaderInfo << endl;*/
        VShaders[Shader] = NewShader;
    }
    else
    {
        //g_Context->Files.Assert << "Double-create on same VShader handle\n";
    }
}
Exemplo n.º 5
0
void ClassBuffer::SearchDir (const char* path) {
    Directory dir(path);

    if (_verbose) {
	printf("searching directory %s\n", path);
    }

    for (int i = 0; i < dir.Count(); ++i) {
        const char* file = dir.File(i);

        if (HeaderFile(file) || (_CPlusPlusFiles && CPlusPlusFile(path))) {
            struct stat filestats;
            char filePath[MAXPATHLEN+1];
            strcpy(filePath, dir.Normalize(path));
            strcat(filePath, file);
        
            if (!IsADirectory(filePath, filestats)) {
                SearchFile(filePath, filestats);
            }
        }
    }            
}