⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 projectfilebuffer.cpp

📁 一个vc中管理资源文件ID的插件
💻 CPP
字号:
/************************************************************************
 *
 *                 Resource ID Organiser Utility Library
 *
 *       (c) Copyright 2000 by Andy Metcalfe (andy.metcalfe@lineone.net)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ProjectFileBuffer.cpp
 *
 *  Description : CProjectFileBuffer - A string array buffer class for
 *                parsing Visual Studio Project (.dsp) files
 *
 *  Compiler    : Microsoft Visual C++ 6.0, Service Pack 3 or 4
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 98/NT
 *
 *  NOTE:
 *
 *    This software is provided "as is" free for personal use. All
 *    title and copyrights in and to the software, including but not
 *    limited to any images, text, etc. incorporated into it, are
 *    owned by Andy Metcalfe, except where acknowledged otherwise.
 *
 *    Your may freely to use this code in your own products, PROVIDED
 *    this notice is not removed or modified.
 *
 *
 *    Visit http://www.resorg.co.uk for latest updates
 *
 ************************************************************************
 *
 *   MODIFICATION HISTORY:
 *
 *           This is a controlled document. See project configuration
 *           control tool for latest version and full version history.
 *
 *    $Archive: /Projects/AddIns/ResOrg/ResOrgUtils/ProjectFileBuffer.cpp $
 *   $Revision: 3 $
 *       $Date: 24/07/01 11:40 $
 *     $Author: Andy $
 *
 *    $History: ProjectFileBuffer.cpp $
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 24/07/01   Time: 11:40
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Shlwapi is no longer used for the PathCombine() function. A wrapper
 * function [CombinePath()] in NGLibrary is used instead.
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 29/11/00   Time: 18:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 *  Added file banners
 *
 * $Nokeywords: $
 *
 ************************************************************************/

// ProjectFileBuffer.cpp : implementation file
//

#include "StdAfx.h"
#include <math.h>
#include "ResOrgUtils_Priv.h"

#include "ResourceSymbol.h"
#include "ReservedSymbolsDlg.h"

#include "ProjectFileBuffer.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif



/////////////////////////////////////////////////////////////////////////////
// CProjectFileBuffer

#define BUFFER_GROWBY 100			// Grow file buffer by 100 lines at a time

#define	BUF_SIZE	1024

#define WHITE_SPACE	_T(" \t")


IMPLEMENT_DYNCREATE(CProjectFileBuffer, CProjectFileBuffer_BASE)

CProjectFileBuffer::CProjectFileBuffer(void)
{
	m_bParsingFile		= FALSE;
}


CProjectFileBuffer::~CProjectFileBuffer(void)
{
}


/////////////////////////////////////////////////////////////////////////////
// CProjectFileBuffer message handlers

void CProjectFileBuffer::Serialize(CArchive& ar) 
{
	ASSERT_VALID(this);
	
	CProjectFileBuffer_BASE::Serialize(ar);
}


/////////////////////////////////////////////////////////////////////////////
// Virtual Overrides


/////////////////////////////////////////////////////////////////////////////
// Operations

int	CProjectFileBuffer::GetFiles(	CStringArray& rarrayFiles,
									const CString& sExt /*= _T("")*/ ) const
{
	rarrayFiles.RemoveAll();

	if (sExt.IsEmpty())
	{
		rarrayFiles.Append(m_arrayFiles);
	}
	else
	{
		for (int n = 0; n < m_arrayFiles.GetSize(); n++)
		{
			CString sFile = m_arrayFiles[n];
			CNGSplitPath path(sFile);
			if (path.GetExtension() == sExt)
			{
				rarrayFiles.Add(sFile);
			}
		}					
	}
	return rarrayFiles.GetSize();
}


/////////////////////////////////////////////////////////////////////////////
// Implementation



/////////////////////////////////////////////////////////////////////////////
// File Read Implementation

/******************************************************************************
 *	Read from an archive
 *
 ******************************************************************************/

BOOL CProjectFileBuffer::Read(CArchive& ar)
{
	return CProjectFileBuffer_BASE::Read(ar);
}


/******************************************************************************
 *	Parse the given line
 *
 ******************************************************************************/

BOOL CProjectFileBuffer::Parse(const CString& sLine)
{
	if (!sLine.IsEmpty())
	{
		if (sLine.Find( _T("# Begin Source File") ) == 0)
		{
			m_bParsingFile = TRUE;
		}
		else if (sLine.Find( _T("# End Source File") ) == 0)
		{
			m_bParsingFile = FALSE;
		}
		else if (m_bParsingFile)
		{
			if (sLine.Find( _T("SOURCE") ) == 0)
			{
				CString sFile = ::After( sLine, _T("=") );

				// Strip quotes
				sFile.TrimLeft( _T("\"") );
				sFile.TrimRight( _T("\"") );

				if (!sFile.IsEmpty() )
				{
					CString sPathName = GetPathName(sFile);
					if (!sPathName.IsEmpty())
					{
						m_arrayFiles.Add(sPathName);
					}
				}
			}
		}
		return TRUE;
	}
	return FALSE;
}


CString CProjectFileBuffer::GetPathName(const CString& sRelativePath) const
{
	CString sPathName;
	if (!sRelativePath.IsEmpty())
	{
		CNGSplitPath path(m_sFileName);
		
		sPathName = ::CombinePath(path.GetDrive() + path.GetDirectory(), sRelativePath);
	}
	return sPathName;
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -