Remove unnecessary sub-projects
This commit is contained in:
parent
784eea3ef7
commit
d94ad58d97
@ -1,263 +0,0 @@
|
|||||||
// Replace an icon group in an executable by one from an ICO file
|
|
||||||
// By Francois-R.Boyer@PolyMtl.ca for Notepad++
|
|
||||||
// 2010-11-20
|
|
||||||
//
|
|
||||||
// This code is based on: Maria Nadejde, "Replacing ICON resources in EXE and DLL files", The Code Project, 13 Nov 2008
|
|
||||||
// ( http://www.codeproject.com/KB/DLL/ICON_Resources.aspx )
|
|
||||||
// original article and code is licenced under The GNU General Public License (GPLv3)
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// this file is part of ChangeIcon
|
|
||||||
// Copyright (C)2010 Francois-R Boyer <Francois-R.Boyer@PolyMtl.ca>
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either
|
|
||||||
// version 2 of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef UNICODE
|
|
||||||
#define UNICODE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _UNICODE
|
|
||||||
#define _UNICODE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stddef.h> // for offsetof
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define IFDEBUG(x) x
|
|
||||||
#else
|
|
||||||
#define IFDEBUG(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOL getMaxIconId_EnumNamesFunc(HANDLE hModule, LPCTSTR lpType, LPTSTR lpName, WORD* lpMaxID)
|
|
||||||
{
|
|
||||||
if(IS_INTRESOURCE(lpName) && (USHORT)lpName>*lpMaxID)
|
|
||||||
*lpMaxID=(USHORT)lpName;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
WORD getMaxIconId(TCHAR* lpFileName)
|
|
||||||
{
|
|
||||||
WORD nMaxID = 0;
|
|
||||||
HINSTANCE hLib = LoadLibraryEx(lpFileName,NULL,DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
|
||||||
if(hLib == NULL) { _tprintf(_T("Unable to load library '%s'\n"), lpFileName); return 0xFFFF; }
|
|
||||||
// Enumerate icon "names" (IDs) to get next available ID
|
|
||||||
if(!EnumResourceNames(hLib, RT_ICON, (ENUMRESNAMEPROC)getMaxIconId_EnumNamesFunc,(LONG_PTR)&nMaxID)) { _tprintf(_T("Unable to enum icons\n")); return 0xFFFF; }
|
|
||||||
FreeLibrary(hLib);
|
|
||||||
IFDEBUG( _tprintf(_T("MaxIcon=%d\n"), nMaxID); )
|
|
||||||
return nMaxID;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Icon {
|
|
||||||
public:
|
|
||||||
// Icon format from http://msdn.microsoft.com/en-us/library/ms997538.aspx
|
|
||||||
// for ICO and EXE files
|
|
||||||
struct ICONDIR { // File header:
|
|
||||||
WORD idReserved; // Reserved (must be 0)
|
|
||||||
WORD idType; // Resource Type (1 for icons)
|
|
||||||
WORD idCount; // How many images?
|
|
||||||
};
|
|
||||||
struct ICONDIRENTRY { // One for each image:
|
|
||||||
BYTE bWidth; // Width, in piexels, of the image
|
|
||||||
BYTE bHeight; // Height, in pixels, of the image (times 2)
|
|
||||||
BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
|
|
||||||
BYTE bReserved; // Reserved (must be 0)
|
|
||||||
WORD wPlanes; // Color Planes
|
|
||||||
WORD wBitCount; // Bits per pixel
|
|
||||||
DWORD dwBytesInRes; // How many bytes in this resource?
|
|
||||||
union {
|
|
||||||
DWORD dwImageOffset;// Where in the file is this image (in ICO file)
|
|
||||||
WORD nID; // the ID (in EXE file)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
static const UINT sizeof_iconDirEntry_ICO = sizeof(ICONDIRENTRY);
|
|
||||||
static const UINT sizeof_iconDirEntry_EXE = offsetof(ICONDIRENTRY,nID)+sizeof(WORD);
|
|
||||||
|
|
||||||
ICONDIR _head;
|
|
||||||
ICONDIRENTRY *_entries;
|
|
||||||
LPBYTE *_imagesData;
|
|
||||||
|
|
||||||
Icon() : _entries(NULL), _imagesData(NULL) { _head.idCount = 0; }
|
|
||||||
void clear() {
|
|
||||||
if(_imagesData) { for(int i=0; i<_head.idCount; ++i) delete _imagesData[i]; delete[] _imagesData; _imagesData = 0; }
|
|
||||||
if(_entries) delete[] _entries; _entries = 0;
|
|
||||||
_head.idCount = 0;
|
|
||||||
}
|
|
||||||
~Icon() { clear(); }
|
|
||||||
|
|
||||||
bool readICO(TCHAR* filename);
|
|
||||||
bool readEXE(TCHAR* lpFileName, LPCTSTR lpResName, UINT resLangId); // Does not currently read image data
|
|
||||||
|
|
||||||
bool writeToEXE(TCHAR* lpFileName, LPCTSTR lpResName, UINT resLangId);
|
|
||||||
|
|
||||||
WORD count() { return _head.idCount; }
|
|
||||||
};
|
|
||||||
|
|
||||||
bool Icon::readICO(TCHAR* filename)
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
HANDLE hFile = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
if(hFile == INVALID_HANDLE_VALUE) { _tprintf(_T("Error opening file '%s' for Reading\n"), filename); return false; }
|
|
||||||
DWORD dwBytesRead;
|
|
||||||
// Read header
|
|
||||||
if(!ReadFile( hFile, &_head, sizeof(_head), &dwBytesRead, NULL )) { _tprintf(_T("Error reading file '%s'\n"), filename); return false; }
|
|
||||||
IFDEBUG( _tprintf(_T("%d icon entries\n"), count()); )
|
|
||||||
// Read entries
|
|
||||||
_entries = new ICONDIRENTRY[count()];
|
|
||||||
if(!ReadFile( hFile, _entries, sizeof(*_entries)*count(), &dwBytesRead, NULL )) { _tprintf(_T("Error reading file '%s'\n"), filename); return false; }
|
|
||||||
// Read images
|
|
||||||
_imagesData=new LPBYTE[count()]; memset(_imagesData, 0, sizeof(LPBYTE)*count());
|
|
||||||
for(int i=0; i<count(); ++i)
|
|
||||||
{
|
|
||||||
IFDEBUG( _tprintf(_T("%d: offset=%d, size=%d\n"), i, _entries[i].dwImageOffset, _entries[i].dwBytesInRes); )
|
|
||||||
_imagesData[i] = (LPBYTE)malloc(_entries[i].dwBytesInRes);
|
|
||||||
if(SetFilePointer(hFile, _entries[i].dwImageOffset, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) { _tprintf(_T("Error moving read pointer in '%s'\n"), filename); return false; }
|
|
||||||
if(!ReadFile(hFile, _imagesData[i], _entries[i].dwBytesInRes, &dwBytesRead, NULL)) { _tprintf(_T("Error reading file '%s'\n"), filename); return false; }
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Icon::readEXE(TCHAR* lpFileName, LPCTSTR lpResName, UINT resLangId)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
clear();
|
|
||||||
HINSTANCE hLib = LoadLibraryEx(lpFileName, NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
|
||||||
if(hLib == NULL) { _tprintf(_T("Unable to load library '%s'\n"), lpFileName); goto error1; }
|
|
||||||
|
|
||||||
HRSRC hRsrc = FindResourceEx(hLib, RT_GROUP_ICON, lpResName, resLangId);
|
|
||||||
if(hRsrc == NULL) { _tprintf(IS_INTRESOURCE(lpResName) ? _T("Icon group %d (lang %d) not found in '%s'\n") : _T("Icon group %s (lang %d) not found in '%s'\n"), lpResName, resLangId, lpFileName); goto error2; }
|
|
||||||
|
|
||||||
HGLOBAL hGlobal = LoadResource(hLib, hRsrc);
|
|
||||||
if(hGlobal == NULL) { _tprintf(IS_INTRESOURCE(lpResName) ? _T("Unable to load icon group %d from '%s'\n") : _T("ReplaceIconResource: icon group %s not found in '%s'\n"), lpResName, lpFileName); goto error2; }
|
|
||||||
|
|
||||||
LPBYTE resData = (BYTE*)LockResource(hGlobal);
|
|
||||||
if(resData == NULL) { _tprintf(_T("Unable to lock resource data\n")); goto error2; }
|
|
||||||
|
|
||||||
LPBYTE readPtr = resData;
|
|
||||||
#define _myRead(ptr, size) { CopyMemory(ptr, readPtr, size); readPtr += size; }
|
|
||||||
_myRead(&_head, sizeof(_head));
|
|
||||||
IFDEBUG( _tprintf(_T("%d icon entries\n"), count()); )
|
|
||||||
_entries = new ICONDIRENTRY[count()];
|
|
||||||
for(int i=0; i<count(); ++i)
|
|
||||||
{
|
|
||||||
_myRead(&_entries[i], sizeof_iconDirEntry_EXE);
|
|
||||||
IFDEBUG( _tprintf(_T("%d: ID=%d\n"), i, _entries[i].nID); )
|
|
||||||
}
|
|
||||||
// NOTE: This routine currently do not load image data from EXE.
|
|
||||||
//_imagesData=new LPBYTE[count()]; memset(_imagesData, sizeof(LPBYTE)*count(), 0);
|
|
||||||
|
|
||||||
#undef _myRead
|
|
||||||
result = true;
|
|
||||||
error3:
|
|
||||||
UnlockResource((HGLOBAL)resData);
|
|
||||||
error2:
|
|
||||||
FreeLibrary(hLib);
|
|
||||||
error1:
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Icon::writeToEXE(TCHAR* lpFileName, LPCTSTR lpResName, UINT resLangId)
|
|
||||||
{
|
|
||||||
Icon oldIcon;
|
|
||||||
// NOTE: This routine currently cannot add an icon groupe, only replace an existing one.
|
|
||||||
if(!oldIcon.readEXE(lpFileName, lpResName, resLangId)) return false;
|
|
||||||
|
|
||||||
//lpInitGrpIconDir is oldIcon
|
|
||||||
oldIcon._head.idReserved = _head.idReserved;
|
|
||||||
|
|
||||||
// Set icon IDs for each icon in the group
|
|
||||||
WORD nMaxID = 0xFFFF;
|
|
||||||
for(int i=0; i<count(); ++i)
|
|
||||||
{
|
|
||||||
if(i<oldIcon.count()) { // use IDs of old icons
|
|
||||||
_entries[i].nID = oldIcon._entries[i].nID;
|
|
||||||
IFDEBUG( _tprintf(_T("replacing icon %d\n"), _entries[i].nID); )
|
|
||||||
} else { // if new icon group has more icons, allocate new IDs
|
|
||||||
if(nMaxID == 0xFFFF && (nMaxID = getMaxIconId(lpFileName)) == 0xFFFF) return false;
|
|
||||||
nMaxID++;
|
|
||||||
_entries[i].nID = nMaxID;
|
|
||||||
IFDEBUG( _tprintf(_T("adding icon %d\n"), _entries[i].nID); )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// _tchmod(lpFileName,_S_IWRITE); // if needed...
|
|
||||||
HANDLE hUpdate = BeginUpdateResource(lpFileName, FALSE);
|
|
||||||
if(hUpdate==NULL) { _tprintf(_T("Unable to update resource\n")); return false; }
|
|
||||||
|
|
||||||
{
|
|
||||||
// Build icon group resource
|
|
||||||
WORD cbRes = sizeof(ICONDIR) + count()*sizeof_iconDirEntry_EXE;
|
|
||||||
BYTE* resData = new BYTE[cbRes];
|
|
||||||
LPBYTE writePtr = resData;
|
|
||||||
#define _myWrite(ptr, size) { CopyMemory(writePtr, ptr, size); writePtr += size; }
|
|
||||||
_myWrite(&_head, sizeof(_head));
|
|
||||||
for(int i=0; i<count(); ++i)
|
|
||||||
_myWrite(&_entries[i], sizeof_iconDirEntry_EXE);
|
|
||||||
#undef _myWrite
|
|
||||||
|
|
||||||
// Replace icon group
|
|
||||||
if(!UpdateResource(hUpdate, RT_GROUP_ICON, lpResName, resLangId, resData, cbRes))
|
|
||||||
{
|
|
||||||
_tprintf(_T("Unable to update icon group\n")); delete[] resData; return false;
|
|
||||||
}
|
|
||||||
IFDEBUG( _tprintf(_T("Updated group %d (lang %d)\n"), lpResName, resLangId); )
|
|
||||||
delete [] resData;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace/add icons
|
|
||||||
for(int i=0; i<count(); ++i)
|
|
||||||
{
|
|
||||||
if(!UpdateResource(hUpdate, RT_ICON, MAKEINTRESOURCE(_entries[i].nID), resLangId, _imagesData[i], _entries[i].dwBytesInRes)) { _tprintf(_T("Unable to update icon %d\n"), _entries[i].nID); return false; }
|
|
||||||
IFDEBUG( _tprintf(_T("Updated icon %d (lang %d)\n"), _entries[i].nID, resLangId); )
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete unused icons
|
|
||||||
for(int i=count(); i<oldIcon.count(); ++i)
|
|
||||||
{
|
|
||||||
if(!UpdateResource(hUpdate, RT_ICON, MAKEINTRESOURCE(oldIcon._entries[i].nID), resLangId, NULL, 0)) { _tprintf(_T("Unable to delete icon %d\n"), oldIcon._entries[i].nID); }
|
|
||||||
IFDEBUG( _tprintf(_T("Removed icon %d (lang %d)\n"), oldIcon._entries[i].nID, resLangId); )
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!EndUpdateResource(hUpdate,FALSE)) { _tprintf(_T("Error in EndUpdateResource\n")); }
|
|
||||||
IFDEBUG( _tprintf(_T("EndUpdateResource\n")); )
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
|
|
||||||
{
|
|
||||||
int nRetCode = 0;
|
|
||||||
|
|
||||||
IFDEBUG( printf("sizeof(TCHAR)=%d\n", sizeof(TCHAR)) );
|
|
||||||
if(argc != 5) {
|
|
||||||
_tprintf(_T("Usage: %s source.ico destination.exe icon_group# icon_lang#\n"), argv[0]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
TCHAR* szICOname = argv[1];
|
|
||||||
TCHAR* szEXEname = argv[2];
|
|
||||||
int groupId = _ttoi(argv[3]);
|
|
||||||
int langId = _ttoi(argv[4]);
|
|
||||||
|
|
||||||
IFDEBUG( _tprintf(_T("ICO='%s' EXE='%s' group#=%d lang#=%d\n"), szICOname, szEXEname, groupId, langId); )
|
|
||||||
|
|
||||||
Icon newIcon; if(!newIcon.readICO(szICOname)) return false;
|
|
||||||
newIcon.writeToEXE(szEXEname, MAKEINTRESOURCE(groupId), langId);
|
|
||||||
|
|
||||||
return nRetCode;
|
|
||||||
}
|
|
@ -1,188 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="8,00"
|
|
||||||
Name="ChangeIcon"
|
|
||||||
ProjectGUID="{5DD32D11-47F0-416C-ADBF-E618A1DE178A}"
|
|
||||||
RootNamespace="ChangeIcon"
|
|
||||||
>
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"
|
|
||||||
/>
|
|
||||||
</Platforms>
|
|
||||||
<ToolFiles>
|
|
||||||
</ToolFiles>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
|
||||||
ConfigurationType="1"
|
|
||||||
CharacterSet="2"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
MinimalRebuild="true"
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
RuntimeLibrary="1"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="true"
|
|
||||||
DebugInformationFormat="4"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
|
||||||
ConfigurationType="1"
|
|
||||||
CharacterSet="2"
|
|
||||||
WholeProgramOptimization="1"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
RuntimeLibrary="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="true"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ChangeIcon.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
@ -1,2 +0,0 @@
|
|||||||
ALL:
|
|
||||||
gcc nppIExplorerShell.cpp -o nppIExplorerShell.exe -mwindows -lshlwapi -Os -s
|
|
@ -1,50 +0,0 @@
|
|||||||
// This file is part of Notepad++ project
|
|
||||||
// Copyright (C)2003 Don HO <don.h@free.fr>
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either
|
|
||||||
// version 2 of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// Note that the GPL places important restrictions on "derived works", yet
|
|
||||||
// it does not provide a detailed definition of that term. To avoid
|
|
||||||
// misunderstandings, we consider an application to constitute a
|
|
||||||
// "derivative work" for the purpose of this license if it does any of the
|
|
||||||
// following:
|
|
||||||
// 1. Integrates source code from Notepad++.
|
|
||||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
|
||||||
// installer, such as those produced by InstallShield.
|
|
||||||
// 3. Links to a library or executes a program that does any of the above.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <shlwapi.h>
|
|
||||||
|
|
||||||
const int CMD_LEN = 512;
|
|
||||||
const int PARAM_LEN = 1024;
|
|
||||||
const char *NPP = "\\notepad++.exe";
|
|
||||||
const char *FLAG_LEXER_HTML = "-lhtml ";
|
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdShow)
|
|
||||||
{
|
|
||||||
char cmd[CMD_LEN];
|
|
||||||
::GetModuleFileName(NULL, cmd, CMD_LEN);
|
|
||||||
PathRemoveFileSpec(cmd);
|
|
||||||
strcat(cmd, NPP);
|
|
||||||
|
|
||||||
char param[PARAM_LEN] = "";
|
|
||||||
|
|
||||||
strcat(strcat(param, FLAG_LEXER_HTML), lpszCmdLine);
|
|
||||||
::MessageBox(NULL, param, "", MB_OK);
|
|
||||||
HINSTANCE hInst = ::ShellExecute(NULL, "open", cmd, param, ".", SW_SHOW);
|
|
||||||
return (UINT)0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252" ?>
|
|
||||||
<Node nodeName="NotepadPlus">
|
|
||||||
<Node nodeName="GUIConfigs" name="">
|
|
||||||
<Node nodeName="GUIConfig" name="name"/>
|
|
||||||
</Node>
|
|
||||||
</Node>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252" ?>
|
|
||||||
<Node nodeName="NotepadPlus">
|
|
||||||
<Node nodeName="Languages" name="">
|
|
||||||
<Node nodeName="Language" name="name"/>
|
|
||||||
</Node>
|
|
||||||
</Node>
|
|
@ -1,56 +0,0 @@
|
|||||||
# this file is part of notepad++
|
|
||||||
# Copyright (C)2003 Don HO ( donho@altern.org )
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either
|
|
||||||
# version 2 of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
.SUFFIXES: .cpp
|
|
||||||
CPP = g++
|
|
||||||
CFLAGS = -Wall -Os -DNDEBUG
|
|
||||||
|
|
||||||
MAINOBJS = xmlUpdater.o
|
|
||||||
TINYXMLOBJS = tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o
|
|
||||||
|
|
||||||
TINYXMLDIR = ../../TinyXml
|
|
||||||
|
|
||||||
OBJS = $(MAINOBJS) $(TINYXMLOBJS)
|
|
||||||
|
|
||||||
PROG = xmlUpdater.exe
|
|
||||||
|
|
||||||
INCLUDEDIR = $(TINYXMLDIR)
|
|
||||||
INCLUDEFLAGS = -I$(INCLUDEDIR)
|
|
||||||
LDFLAGS =
|
|
||||||
#-mwindows -lshlwapi -Os -s
|
|
||||||
|
|
||||||
ALL : $(PROG)
|
|
||||||
|
|
||||||
|
|
||||||
$(PROG) : $(OBJS)
|
|
||||||
$(CPP) -o $@ $(OBJS) $(LDFLAGS)
|
|
||||||
|
|
||||||
xmlUpdater.o : $(INCLUDEDIR)/tinyxml.h
|
|
||||||
$(CPP) -c xmlUpdater.cpp -o $@ $(INCLUDEFLAGS)
|
|
||||||
|
|
||||||
tinystr.o: $(TINYXMLDIR)/tinystr.h $(TINYXMLDIR)/tinyxml.h
|
|
||||||
$(CPP) $(CFLAGS) -c $(TINYXMLDIR)/tinystr.cpp -o $@ $(INCLUDEFLAGS)
|
|
||||||
|
|
||||||
tinyxml.o: $(TINYXMLDIR)/tinyxml.h
|
|
||||||
$(CPP) $(CFLAGS) -c $(TINYXMLDIR)/tinyxml.cpp -o $@ $(INCLUDEFLAGS)
|
|
||||||
|
|
||||||
tinyxmlerror.o: $(TINYXMLDIR)/tinyxml.h
|
|
||||||
$(CPP) $(CFLAGS) -c $(TINYXMLDIR)/tinyxmlerror.cpp -o $@ $(INCLUDEFLAGS)
|
|
||||||
|
|
||||||
tinyxmlparser.o: $(TINYXMLDIR)/tinyxml.h
|
|
||||||
$(CPP) $(CFLAGS) -c $(TINYXMLDIR)/tinyxmlparser.cpp -o $@ $(INCLUDEFLAGS)
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252" ?>
|
|
||||||
<NotepadPlus>
|
|
||||||
<LexerStyles>
|
|
||||||
<LexerType name="searchResult" desc="Search result" ext="">
|
|
||||||
<WordsStyle name="DEFAULT" action="remove" />
|
|
||||||
<WordsStyle name="HEARDER" action="remove" />
|
|
||||||
<WordsStyle name="NUMBER" action="remove" />
|
|
||||||
<WordsStyle name="HIT WORD" action="remove" />
|
|
||||||
<WordsStyle name="KEYWORD1" action="remove" />
|
|
||||||
<WordsStyle name="KEYWORD2" action="remove" />
|
|
||||||
<WordsStyle name="SEARCH HEADER" action="remove" />
|
|
||||||
<WordsStyle name="FILE HEADER" action="remove" />
|
|
||||||
<WordsStyle name="LINE NUMBER" action="remove" />
|
|
||||||
<WordsStyle name="SELECTED LINE" action="remove" />
|
|
||||||
</LexerType>
|
|
||||||
</LexerStyles>
|
|
||||||
</NotepadPlus>
|
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252" ?>
|
|
||||||
<Node nodeName="NotepadPlus">
|
|
||||||
<Node nodeName="LexerStyles">
|
|
||||||
<Node nodeName="LexerType" name="name">
|
|
||||||
<Node nodeName="WordsStyle" name="name"/>
|
|
||||||
</Node>
|
|
||||||
</Node>
|
|
||||||
<Node nodeName="GlobalStyles">
|
|
||||||
<Node nodeName="WidgetStyle" name="name" />
|
|
||||||
</Node>
|
|
||||||
</Node>
|
|
||||||
|
|
@ -1,346 +0,0 @@
|
|||||||
// This file is part of Notepad++ project
|
|
||||||
// Copyright (C)2003 Don HO <don.h@free.fr>
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either
|
|
||||||
// version 2 of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// Note that the GPL places important restrictions on "derived works", yet
|
|
||||||
// it does not provide a detailed definition of that term. To avoid
|
|
||||||
// misunderstandings, we consider an application to constitute a
|
|
||||||
// "derivative work" for the purpose of this license if it does any of the
|
|
||||||
// following:
|
|
||||||
// 1. Integrates source code from Notepad++.
|
|
||||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
|
||||||
// installer, such as those produced by InstallShield.
|
|
||||||
// 3. Links to a library or executes a program that does any of the above.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include "tinyxml.h"
|
|
||||||
#define MODEL_INVALID 1
|
|
||||||
#define SRC_INVALID 2
|
|
||||||
#define DEST_INVALID 3
|
|
||||||
|
|
||||||
static bool isInList(const char *token2Find, char *list2Clean) {
|
|
||||||
char word[1024];
|
|
||||||
bool isFileNamePart = false;
|
|
||||||
|
|
||||||
for (int i = 0, j = 0 ; i <= int(strlen(list2Clean)) ; i++)
|
|
||||||
{
|
|
||||||
if ((list2Clean[i] == ' ') || (list2Clean[i] == '\0'))
|
|
||||||
{
|
|
||||||
if ((j) && (!isFileNamePart))
|
|
||||||
{
|
|
||||||
word[j] = '\0';
|
|
||||||
j = 0;
|
|
||||||
bool bingo = !strcmp(token2Find, word);
|
|
||||||
|
|
||||||
if (bingo)
|
|
||||||
{
|
|
||||||
int wordLen = int(strlen(word));
|
|
||||||
int prevPos = i - wordLen;
|
|
||||||
|
|
||||||
for (i = i + 1 ; i <= int(strlen(list2Clean)) ; i++, prevPos++)
|
|
||||||
list2Clean[prevPos] = list2Clean[i];
|
|
||||||
|
|
||||||
list2Clean[prevPos] = '\0';
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (list2Clean[i] == '"')
|
|
||||||
{
|
|
||||||
isFileNamePart = !isFileNamePart;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
word[j++] = list2Clean[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void update(TiXmlNode *modelNode, TiXmlNode *srcNode, TiXmlNode *destNode) {
|
|
||||||
TiXmlNode *srcChildNode = NULL;
|
|
||||||
TiXmlNode *destChildNode = NULL;
|
|
||||||
TiXmlNode *modelChildNode = modelNode->FirstChild("Node");
|
|
||||||
|
|
||||||
if (!srcNode) return;
|
|
||||||
|
|
||||||
for (modelChildNode = modelNode->FirstChild("Node");
|
|
||||||
modelChildNode;
|
|
||||||
modelChildNode = modelChildNode->NextSibling("Node"))
|
|
||||||
{
|
|
||||||
const char *nodeName = (modelChildNode->ToElement())->Attribute("nodeName");
|
|
||||||
const char *name = (modelChildNode->ToElement())->Attribute("name");
|
|
||||||
if (nodeName)
|
|
||||||
{
|
|
||||||
srcChildNode = srcNode->FirstChild(nodeName);
|
|
||||||
if (!srcChildNode) continue;
|
|
||||||
|
|
||||||
destChildNode = destNode->FirstChild(nodeName);
|
|
||||||
if (!destChildNode)
|
|
||||||
{
|
|
||||||
//Insertion
|
|
||||||
destNode->InsertEndChild(*srcChildNode);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (name && name[0])
|
|
||||||
{
|
|
||||||
srcChildNode = srcNode->FirstChild(nodeName);
|
|
||||||
while (srcChildNode)
|
|
||||||
{
|
|
||||||
const char *attrib = (srcChildNode->ToElement())->Attribute(name);
|
|
||||||
if (attrib)
|
|
||||||
{
|
|
||||||
const char *action = (srcChildNode->ToElement())->Attribute("action");
|
|
||||||
bool remove = false;
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
if (action && !strcmp(action, "remove"))
|
|
||||||
remove = true;
|
|
||||||
|
|
||||||
destChildNode = destNode->FirstChild(nodeName);
|
|
||||||
while (destChildNode)
|
|
||||||
{
|
|
||||||
const char *attribDest = (destChildNode->ToElement())->Attribute(name);
|
|
||||||
if ((attribDest) && (!strcmp(attrib, attribDest)))
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
destChildNode = destChildNode->NextSibling(nodeName);
|
|
||||||
}
|
|
||||||
if (remove)
|
|
||||||
{
|
|
||||||
if (found) destNode->RemoveChild(destChildNode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (found)
|
|
||||||
update(modelChildNode, srcChildNode, destChildNode);
|
|
||||||
else
|
|
||||||
destNode->InsertEndChild(*srcChildNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
srcChildNode = srcChildNode->NextSibling(nodeName);
|
|
||||||
} // while srcChildNode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
update(modelChildNode, srcChildNode, destChildNode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
if (argc != 4)
|
|
||||||
{
|
|
||||||
printf("Syntax : xmlUpdater model.xml src.xml dest.xml");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *xmlModelPath = argv[1];
|
|
||||||
char *xmlSrcPath = argv[2];
|
|
||||||
char *xmlDestPath = argv[3];
|
|
||||||
|
|
||||||
//printf("%s\n", xmlModelPath);
|
|
||||||
//printf("%s\n", xmlSrcPath);
|
|
||||||
//printf("%s\n", xmlDestPath);
|
|
||||||
|
|
||||||
TiXmlDocument *pXmlModel = NULL;
|
|
||||||
TiXmlDocument *pXmlSrc = NULL;
|
|
||||||
TiXmlDocument *pXmlDest = NULL;
|
|
||||||
|
|
||||||
try {
|
|
||||||
pXmlModel = new TiXmlDocument(xmlModelPath);
|
|
||||||
bool loadOkay = pXmlModel->LoadFile();
|
|
||||||
if (!loadOkay) throw int(MODEL_INVALID);
|
|
||||||
|
|
||||||
pXmlSrc = new TiXmlDocument(xmlSrcPath);
|
|
||||||
loadOkay = pXmlSrc->LoadFile();
|
|
||||||
if (!loadOkay) throw int(SRC_INVALID);
|
|
||||||
|
|
||||||
pXmlDest = new TiXmlDocument(xmlDestPath);
|
|
||||||
loadOkay = pXmlDest->LoadFile();
|
|
||||||
if (!loadOkay) throw int(DEST_INVALID);
|
|
||||||
|
|
||||||
TiXmlNode *root = pXmlModel->FirstChild("Node");
|
|
||||||
const char *nodeRootName = (root->ToElement())->Attribute("nodeName");
|
|
||||||
if (nodeRootName)
|
|
||||||
{
|
|
||||||
TiXmlNode *srcRoot = pXmlSrc->FirstChild(nodeRootName);
|
|
||||||
if (!srcRoot) throw int(4);
|
|
||||||
TiXmlNode *destRoot = pXmlDest->FirstChild(nodeRootName);
|
|
||||||
if (!destRoot)
|
|
||||||
{
|
|
||||||
throw int(DEST_INVALID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
update(root, srcRoot, destRoot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (int errMsg) {
|
|
||||||
char *msg;
|
|
||||||
if (errMsg == MODEL_INVALID)
|
|
||||||
msg = "Model file is invalidated";
|
|
||||||
if (errMsg == SRC_INVALID)
|
|
||||||
msg = "Source file is invalidated";
|
|
||||||
if (errMsg == DEST_INVALID)
|
|
||||||
msg = "File to update is invalidated";
|
|
||||||
|
|
||||||
if (pXmlModel) delete pXmlModel;
|
|
||||||
if (pXmlSrc) delete pXmlSrc;
|
|
||||||
if (pXmlDest) delete pXmlDest;
|
|
||||||
|
|
||||||
printf(msg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pXmlDest->SaveFile();
|
|
||||||
|
|
||||||
delete pXmlModel;
|
|
||||||
delete pXmlSrc;
|
|
||||||
delete pXmlDest;
|
|
||||||
printf("Update successful");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
const char FLAG_SILENT[] = "-silent";
|
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdShow)
|
|
||||||
//int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
bool isSilentMode = isInList(FLAG_SILENT, lpszCmdLine);
|
|
||||||
|
|
||||||
int argc=0;
|
|
||||||
LPSTR argv[10];
|
|
||||||
LPSTR p, q;
|
|
||||||
|
|
||||||
argv[argc] = "xmlUpdater.exe";
|
|
||||||
// Parse command line handling quotes.
|
|
||||||
p = lpszCmdLine;
|
|
||||||
while (*p)
|
|
||||||
{
|
|
||||||
// for each argument
|
|
||||||
while ((*p) && (*p == ' '))
|
|
||||||
p++; // skip over leading spaces
|
|
||||||
if (*p == '\042')
|
|
||||||
{
|
|
||||||
p++; // skip "
|
|
||||||
q = p;
|
|
||||||
// scan to end of argument
|
|
||||||
// doesn't handle embedded quotes
|
|
||||||
while ((*p) && (*p != '\042'))
|
|
||||||
p++;
|
|
||||||
argv[++argc] = q;
|
|
||||||
if (*p)
|
|
||||||
*p++ = '\0';
|
|
||||||
}
|
|
||||||
else if (*p)
|
|
||||||
{
|
|
||||||
// delimited by spaces
|
|
||||||
q = p;
|
|
||||||
while ((*p) && (*p != ' '))
|
|
||||||
p++;
|
|
||||||
argv[++argc] = q;
|
|
||||||
if (*p)
|
|
||||||
*p++ = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argv[++argc] = (LPSTR)NULL;
|
|
||||||
|
|
||||||
if (argc < 4)
|
|
||||||
{
|
|
||||||
//printf();
|
|
||||||
if (!isSilentMode)
|
|
||||||
MessageBox(NULL, "xmlUpdater model.xml src.xml dest.xml", "Syntax", MB_OK);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *xmlModelPath = argv[1];
|
|
||||||
char *xmlSrcPath = argv[2];
|
|
||||||
char *xmlDestPath = argv[3];
|
|
||||||
|
|
||||||
//printf("%s\n", xmlModelPath);
|
|
||||||
//printf("%s\n", xmlSrcPath);
|
|
||||||
//printf("%s\n", xmlDestPath);
|
|
||||||
|
|
||||||
TiXmlDocument *pXmlModel = NULL;
|
|
||||||
TiXmlDocument *pXmlSrc = NULL;
|
|
||||||
TiXmlDocument *pXmlDest = NULL;
|
|
||||||
|
|
||||||
try {
|
|
||||||
pXmlModel = new TiXmlDocument(xmlModelPath);
|
|
||||||
bool loadOkay = pXmlModel->LoadFile();
|
|
||||||
if (!loadOkay) throw int(MODEL_INVALID);
|
|
||||||
|
|
||||||
pXmlSrc = new TiXmlDocument(xmlSrcPath);
|
|
||||||
loadOkay = pXmlSrc->LoadFile();
|
|
||||||
if (!loadOkay) throw int(SRC_INVALID);
|
|
||||||
|
|
||||||
pXmlDest = new TiXmlDocument(xmlDestPath);
|
|
||||||
loadOkay = pXmlDest->LoadFile();
|
|
||||||
if (!loadOkay) throw int(DEST_INVALID);
|
|
||||||
|
|
||||||
TiXmlNode *root = pXmlModel->FirstChild("Node");
|
|
||||||
const char *nodeRootName = (root->ToElement())->Attribute("nodeName");
|
|
||||||
if (nodeRootName)
|
|
||||||
{
|
|
||||||
TiXmlNode *srcRoot = pXmlSrc->FirstChild(nodeRootName);
|
|
||||||
if (!srcRoot) throw int(4);
|
|
||||||
TiXmlNode *destRoot = pXmlDest->FirstChild(nodeRootName);
|
|
||||||
if (!destRoot)
|
|
||||||
{
|
|
||||||
throw int(DEST_INVALID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
update(root, srcRoot, destRoot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (int errMsg) {
|
|
||||||
char *msg;
|
|
||||||
if (errMsg == MODEL_INVALID)
|
|
||||||
msg = "Model file is invalidated";
|
|
||||||
if (errMsg == SRC_INVALID)
|
|
||||||
msg = "Source file is invalidated";
|
|
||||||
if (errMsg == DEST_INVALID)
|
|
||||||
msg = "File to update is invalidated";
|
|
||||||
|
|
||||||
if (pXmlModel) delete pXmlModel;
|
|
||||||
if (pXmlSrc) delete pXmlSrc;
|
|
||||||
if (pXmlDest) delete pXmlDest;
|
|
||||||
|
|
||||||
if (!isSilentMode)
|
|
||||||
MessageBox(NULL, msg, "Update Failure", MB_OK);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pXmlDest->SaveFile();
|
|
||||||
|
|
||||||
delete pXmlModel;
|
|
||||||
delete pXmlSrc;
|
|
||||||
delete pXmlDest;
|
|
||||||
if (!isSilentMode)
|
|
||||||
MessageBox(NULL, "Update successful", "Update status", MB_OK);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
@ -1,224 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="8,00"
|
|
||||||
Name="xmlUpdater"
|
|
||||||
ProjectGUID="{89EB9F92-B72D-46D3-879E-D6BF8403CF42}"
|
|
||||||
RootNamespace="xmlUpdater"
|
|
||||||
Keyword="Win32Proj"
|
|
||||||
>
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"
|
|
||||||
/>
|
|
||||||
</Platforms>
|
|
||||||
<ToolFiles>
|
|
||||||
</ToolFiles>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="Debug"
|
|
||||||
IntermediateDirectory="Debug"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
CharacterSet="2"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="..\..\TinyXml;..\..\MISC\Common"
|
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
|
||||||
MinimalRebuild="true"
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
RuntimeLibrary="1"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
PrecompiledHeaderThrough=""
|
|
||||||
AssemblerOutput="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="true"
|
|
||||||
DebugInformationFormat="4"
|
|
||||||
CompileAs="2"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
OutputFile="$(OutDir)/../xmlUpdater.exe"
|
|
||||||
LinkIncremental="2"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
ProgramDatabaseFile="$(OutDir)/xmlUpdater.pdb"
|
|
||||||
SubSystem="1"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="Release"
|
|
||||||
IntermediateDirectory="Release"
|
|
||||||
ConfigurationType="1"
|
|
||||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
|
||||||
CharacterSet="2"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="..\..\TinyXml;..\..\MISC\Common"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
|
||||||
RuntimeLibrary="0"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="true"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
OutputFile="$(OutDir)/../xmlUpdater.exe"
|
|
||||||
LinkIncremental="1"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
SubSystem="1"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\TinyXml\tinystr.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\TinyXml\tinyxml.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\TinyXml\tinyxmlerror.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\TinyXml\tinyxmlparser.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\xmlUpdater.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\TinyXml\tinystr.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\TinyXml\tinyxml.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
Loading…
Reference in New Issue
Block a user