Beispiel #1
0
Bool AssertPathExists(const Filename &fn)
{
	if (GeFExist(fn, true))
		return true;

	CFilenameArray pfnDir;
	Filename fnDir = fn;
	Bool bRet = false;
	Int32 a;
	Filename** ppfn;

	while (!GeFExist(fnDir, true))
	{
		Filename* pfn = pfnDir.InsertAt(0);
		if (!pfn)
			goto _error;
		*pfn = fnDir.GetFile();
		fnDir = fnDir.GetDirectory();
		if (!fnDir.Content())
		{
			return false;
		}
	}

	ppfn = pfnDir.GetArray()->GetArray();
	for (a = 0; a < pfnDir.GetElementCount(); a++)
	{
		fnDir += fnDir + *(ppfn[a]);
		if (GeFExist(fnDir, true))
			continue;
		if (!GeFCreateDir(fnDir))
			goto _error;
	}

	bRet = true;
_error:
	return bRet;
}
Beispiel #2
0
Bool ReadPreset(const Filename& fnPreset)
{
	AutoAlloc <BaseFile> pFile;
	if (!pFile)
		return false;

	Filename fnTemp;
	PresetElement* pPreset;
	String strName;
	Int32 n;
	CDynamicArray <char> arLine;
	char* pszLine;
	Bool bHeaderRead = false;
	String str;

	fnTemp = fnPreset.GetFile();
	fnTemp.ClearSuffix();
	strName = fnTemp.GetString();
	bHeaderRead = false;

	for (n = 0; n < g_Presets.GetElementCount(); n++)
	{
		if (g_Presets[n]->strName == strName)
			break;
	}
	if (n != g_Presets.GetElementCount())
		return false;

	pPreset = g_Presets.GetNextObject();
	if (!pPreset)
		return false;

	pPreset->strName = strName;
	if (!pFile->Open(fnPreset))
		return false;

	while (ReadLine(pFile, arLine))
	{
		pszLine = arLine.GetArray();

		if (!bHeaderRead)
		{
			if (strstr(pszLine, FILE_HEADER) == pszLine)
			{
				bHeaderRead = true;
				continue;
			}
		}
		if (!bHeaderRead)
			break;

		while (*pszLine != '\0')
		{
			if (strstr(pszLine, ORIG_PATH) == pszLine)
			{
				pszLine += strlen(ORIG_PATH);
				ReadString(pszLine, pPreset->strOrigin);
			}
			if (strstr(pszLine, DEST_PATH) == pszLine)
			{
				pszLine += strlen(DEST_PATH);
				ReadString(pszLine, pPreset->strDestination);
			}
			if (strstr(pszLine, CREATE_ZIP) == pszLine)
			{
				pszLine += strlen(CREATE_ZIP);
				ReadBool(pszLine, pPreset->bCreateZipFile);
			}
			if (strstr(pszLine, CREATE_ZIP_COMPRESSION) == pszLine)
			{
				pszLine += strlen(CREATE_ZIP_COMPRESSION);
				ReadInt32(pszLine, pPreset->lCreateZipCompressionLevel);
			}
			if (strstr(pszLine, CHECK_VERSION) == pszLine)
			{
				pszLine += strlen(CHECK_VERSION);
				ReadBool(pszLine, pPreset->bCheckVersion);
			}
			if (strstr(pszLine, PARSE_SYMBOLS) == pszLine)
			{
				pszLine += strlen(PARSE_SYMBOLS);
				ReadBool(pszLine, pPreset->bParseSymbols);
			}
			if (strstr(pszLine, WRITE_BUILD) == pszLine)
			{
				pszLine += strlen(WRITE_BUILD);
				ReadBool(pszLine, pPreset->bWriteBuildInfo);
			}
			if (strstr(pszLine, REMOVE_SCC) == pszLine)
			{
				pszLine += strlen(REMOVE_SCC);
				ReadBool(pszLine, pPreset->bRemoveSCC);
			}
			if (strstr(pszLine, BATCH) == pszLine)
			{
				pszLine += strlen(BATCH);
				ReadBool(pszLine, pPreset->bBatch);
			}
			if (strstr(pszLine, PASSWORD) == pszLine)
			{
				pszLine += strlen(PASSWORD);
				ReadString(pszLine, pPreset->strPassword);
				pPreset->strPassword = DecryptPassword(pPreset->strPassword);
			}
			if (strstr(pszLine, FILTER_STRING) == pszLine)
			{
				pszLine += strlen(FILTER_STRING);
				FilterElement* pFilter = pPreset->arFilters.GetNextObject();
				if (!pFilter)
					continue;
				ReadString(pszLine, pFilter->str);

				if (strstr(pszLine, FILTER_CONDITION) == pszLine)
				{
					pszLine += strlen(FILTER_CONDITION);
					ReadString(pszLine, str);
					if (str == W_FILTER_COND_FN_IS) pFilter->lCondition = FILTER_COND_FN_IS;
					else if (str == W_FILTER_COND_FN_EXT) pFilter->lCondition = FILTER_COND_FN_EXT;
					else if (str == W_FILTER_COND_PATH_CONTAINS) pFilter->lCondition = FILTER_COND_PATH_CONTAINS;
					else if (str == W_FILTER_COND_PATH_IS) pFilter->lCondition = FILTER_COND_PATH_IS;
					else if (str == W_FILTER_COND_DIRECTORY_IS) pFilter->lCondition = FILTER_COND_DIRECTORY_IS;
					else DebugAssert(false);
				}
				if (strstr(pszLine, FILTER_ACTION) == pszLine)
				{
					pszLine += strlen(FILTER_ACTION);
					ReadString(pszLine, str);
					if (str == W_FILTER_ACTION_INCLUDE) pFilter->lAction = FILTER_ACTION_INCLUDE;
					else if (str == W_FILTER_ACTION_EXCLUDE) pFilter->lAction = FILTER_ACTION_EXCLUDE;
					else if (str == W_FILTER_ACTION_RENAME) pFilter->lAction = FILTER_ACTION_RENAME;
					else if (str == W_FILTER_ACTION_COMPILE_INCL) pFilter->lAction = FILTER_ACTION_COMPILE_INCL;
					else if (str == W_FILTER_ACTION_MOVE_TO) pFilter->lAction = FILTER_ACTION_MOVE_TO;
					else if (str == W_FILTER_ACTION_FORCE_COPY) pFilter->lAction = FILTER_ACTION_FORCE_COPY;
					else if (str == W_FILTER_ACTION_COMPILE_INCL_KILL) pFilter->lAction = FILTER_ACTION_COMPILE_INCL_KILL;
					else DebugAssert(false);
				}
				if (strstr(pszLine, FILTER_RENAME) == pszLine)
				{
					DebugAssert(pFilter->lAction == FILTER_ACTION_RENAME);
					pszLine += strlen(FILTER_RENAME);
					ReadString(pszLine, pFilter->strRename);
				}
				else
					DebugAssert(pFilter->lAction != FILTER_ACTION_RENAME);
				if (strstr(pszLine, FILTER_FLAG) == pszLine)
				{
					pszLine += strlen(FILTER_FLAG);
					ReadString(pszLine, str);
					if (str == W_FILTER_FLAG_SET_XBIT) pFilter->bSetXBit = true;
					else DebugAssert(false);
				}
			}
			//if (pszLastPos != pszLine) always skip until the end of the line
			break;
		}
	}
	pFile->Close();
	pPreset->ulCRC = GetPresetCrc(pPreset);

	return true;
}
void ApplinkExporter::WriteExportFile(BaseContainer* bc, PolygonObject* ob, BaseFile* objfile, ExportObject& mObject, LONG vcnt, LONG pcnt)
{
	const CPolygon* padr = ob->GetPolygonR();
	Bool expUV = bc->GetBool(IDC_CHK_EXP_UV);
	Bool expMat = bc->GetBool(IDC_CHK_EXP_MAT);
	String str;

	if(expMat && materialArray.GetCount() > 0)
	{
		Filename fileMatObj;
		fileMatObj.SetFile(GetActiveDocument()->GetDocumentName());
		fileMatObj.SetSuffix("mtl");

		str = "mtllib " + fileMatObj.GetFile().GetString() + "\n";
		this->WriteString(str, objfile);
		this->WriteEndLine(objfile);
	}

	str = "g " + ob->GetName() + "\n";
	this->WriteString(str, objfile);
	this->WriteEndLine(objfile);

	// vertex positions
	ApplinkExporter::WriteVertexPositions(objfile, mObject, vcnt);
	//UV
	if(expUV)
		ApplinkExporter::WriteUVWTag(objfile, mObject, pcnt, padr);

	//Polygon faces v/vt/vn (v//vn)
	str = "# begin " + LongToString(pcnt) + " faces\n";
	this->WriteString(str, objfile);

	LONG y=0;
	String prevMat = "", currMat = "";

	for (LONG i = 0; i < pcnt; i++)
	{
		if(expMat && materialArray.GetCount() > 0)
		{
			currMat = mObject.tempMats[mObject.pmatidxArray[i]]->GetName();
			if(currMat != prevMat)
			{
				str = "usemtl " + currMat + "\n";
				this->WriteString(str, objfile);
				prevMat = currMat;
			}
		}

		//GePrint("Polygon[" + LongToString(i) + "] " + LongToString(vadr[i].a) + ", " + LongToString(vadr[i].b) + ", " + LongToString(vadr[i].c) + ", " + LongToString(vadr[i].d));
		str = "f";
		//GePrint("poly vertices: " + LongToString(mObject.Fpvnb[i]));
		for(LONG j = 0; j < mObject.Fpvnb[i]; j++)
		{			
			str += " ";
			str += LongToString(mObject.Fv[y+j] + 1 + vpcnt);

			if(expUV && mObject.Fvt.GetCount() > 0)
			{
				str += "/";
				str += LongToString(mObject.Fvt[y+j] + 1 + vtcnt);
			}
		}

		str += "\n";
		//GePrint("str = " + str);
		this->WriteString(str, objfile);
		y += mObject.Fpvnb[i];
	}

	str = "# end " + LongToString(pcnt) + " faces\n";
	this->WriteString(str, objfile);
	this->WriteEndLine(objfile);
}
Beispiel #4
0
void AddFilename(Filename &fn, const Filename fnDest)
{
	if (!fnDest.Content())
		return;
	AddFilename1(fn, fnDest.GetDirectory(), fnDest.GetFile());
}
Beispiel #5
0
void AddFilename1(Filename &fn, const Filename fnDir, const Filename fnFile)
{
	if (fnDir.Content())
		AddFilename1(fn, fnDir.GetDirectory(), fnDir.GetFile());
	fn += fnFile;
}