mirror of
https://github.com/N3xoX1/sciterui.git
synced 2026-06-17 04:16:14 -07:00
Add resource_packer
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
/.vs
|
||||
/bin
|
||||
/build
|
||||
*.user
|
||||
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.7.34018.315
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sciterui", "src\sciterui\sciterui.vcxproj", "{847B64EE-2C78-48F9-912B-D700F2A5CB91}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resource_packer", "src\resource_packer\resource_packer.vcxproj", "{61B81F77-92C0-4C94-A893-7458FBE76C0B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -15,6 +17,10 @@ Global
|
||||
{847B64EE-2C78-48F9-912B-D700F2A5CB91}.Debug|x64.Build.0 = Debug|x64
|
||||
{847B64EE-2C78-48F9-912B-D700F2A5CB91}.Release|x64.ActiveCfg = Release|x64
|
||||
{847B64EE-2C78-48F9-912B-D700F2A5CB91}.Release|x64.Build.0 = Release|x64
|
||||
{61B81F77-92C0-4C94-A893-7458FBE76C0B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{61B81F77-92C0-4C94-A893-7458FBE76C0B}.Debug|x64.Build.0 = Debug|x64
|
||||
{61B81F77-92C0-4C94-A893-7458FBE76C0B}.Release|x64.ActiveCfg = Release|x64
|
||||
{61B81F77-92C0-4C94-A893-7458FBE76C0B}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
#pragma once
|
||||
|
||||
// clang-format off
|
||||
unsigned char basedll[] = {
|
||||
0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
|
||||
0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00,
|
||||
0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68,
|
||||
0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f,
|
||||
0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20,
|
||||
0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x09, 0x28, 0x3d, 0xdf, 0x4d, 0x49, 0x53, 0x8c, 0x4d, 0x49, 0x53, 0x8c, 0x4d, 0x49, 0x53, 0x8c,
|
||||
0x06, 0xcc, 0xac, 0x8c, 0x4c, 0x49, 0x53, 0x8c, 0x06, 0xcc, 0x51, 0x8d, 0x4c, 0x49, 0x53, 0x8c,
|
||||
0x52, 0x69, 0x63, 0x68, 0x4d, 0x49, 0x53, 0x8c, 0x50, 0x45, 0x00, 0x00, 0x64, 0x86, 0x02, 0x00,
|
||||
0x67, 0x8c, 0xfc, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x22, 0x20,
|
||||
0x0b, 0x02, 0x0e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x60, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x20, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x2e, 0x72, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x2e, 0x72, 0x73, 0x72, 0x63, 0x00, 0x00, 0x00,
|
||||
0x68, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40,
|
||||
0x00, 0x00, 0x00, 0x00, 0x67, 0x8c, 0xfc, 0x67, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
|
||||
0x6c, 0x00, 0x00, 0x00, 0x50, 0x10, 0x00, 0x00, 0x50, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x67, 0x8c, 0xfc, 0x67, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x47, 0x43, 0x54, 0x4c, 0x00, 0x10, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x2e, 0x72, 0x64, 0x61,
|
||||
0x74, 0x61, 0x00, 0x00, 0x38, 0x10, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x2e, 0x72, 0x64, 0x61,
|
||||
0x74, 0x61, 0x24, 0x76, 0x6f, 0x6c, 0x74, 0x6d, 0x64, 0x00, 0x00, 0x00, 0x50, 0x10, 0x00, 0x00,
|
||||
0x6c, 0x00, 0x00, 0x00, 0x2e, 0x72, 0x64, 0x61, 0x74, 0x61, 0x24, 0x7a, 0x7a, 0x7a, 0x64, 0x62,
|
||||
0x67, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x2e, 0x72, 0x73, 0x72,
|
||||
0x63, 0x24, 0x30, 0x31, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x2e, 0x72, 0x73, 0x72, 0x63, 0x24, 0x30, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x0a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x80,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x09, 0x04, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
// clang-format on
|
||||
@@ -0,0 +1,145 @@
|
||||
#include "base_dll.h"
|
||||
#include <Windows.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <sciterui/file.h>
|
||||
#include <sciterui/path.h>
|
||||
#include <sciterui/std_string.h>
|
||||
|
||||
using namespace SciterUI;
|
||||
|
||||
bool ProcessDir(const Path & targetFile, const Path & sourceDir, const char * subdir, bool verbose)
|
||||
{
|
||||
typedef std::map<std::string, LPCWSTR> RESOURCE_MAP;
|
||||
RESOURCE_MAP ResourceMap;
|
||||
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("PNG", L"PNG"));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("JPG", L"JPG"));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("GIF", L"GIF"));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("BMP", RT_BITMAP));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("ICO", RT_GROUP_ICON));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("CUR", RT_GROUP_CURSOR));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("HTM", RT_HTML));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("HTML", RT_HTML));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("CSS", L"CSS"));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("INI", L"LANG"));
|
||||
ResourceMap.insert(RESOURCE_MAP::value_type("LNG", L"LANG"));
|
||||
|
||||
HANDLE update = BeginUpdateResourceW(stdstr(targetFile).ToUTF16().c_str(), false);
|
||||
if (update == nullptr)
|
||||
{
|
||||
std::cout << "Error: failed to BeginUpdateResource on \"" << targetFile << "\n"
|
||||
<< std::endl;
|
||||
targetFile.FileDelete();
|
||||
return false;
|
||||
}
|
||||
|
||||
Path targetDir(sourceDir, "*.*");
|
||||
targetDir.AppendDirectory(subdir);
|
||||
uint32_t itemCount = 0;
|
||||
if (targetDir.FindFirst())
|
||||
{
|
||||
do
|
||||
{
|
||||
RESOURCE_MAP::const_iterator iter = ResourceMap.find(stdstr(targetDir.GetExtension()).ToUpper().c_str());
|
||||
if (iter == ResourceMap.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
itemCount += 1;
|
||||
if (itemCount == 20)
|
||||
{
|
||||
itemCount = 0;
|
||||
BOOL closed = ::EndUpdateResource(update, FALSE);
|
||||
if (closed)
|
||||
{
|
||||
update = ::BeginUpdateResource(stdstr(targetFile).ToUTF16().c_str(), FALSE);
|
||||
if (update == nullptr)
|
||||
{
|
||||
std::cout << "Error: Failed to BeginUpdateResource on \"" << targetFile << "\"" << std::endl;
|
||||
targetFile.FileDelete();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t * strType = iter->second;
|
||||
File fileData;
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "Processing " << (((ULONG_PTR)strType) <= 0xFFFF ? stdstr_f("%d", (WORD)(ULONG_PTR)strType).c_str() : stdstr().FromUTF16(strType).c_str()) << " - " << targetDir.GetNameExtension().c_str() << std::endl;
|
||||
}
|
||||
if (fileData.Open(targetDir, File::modeRead))
|
||||
{
|
||||
uint32_t dataSize = fileData.GetLength();
|
||||
std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(dataSize);
|
||||
fileData.Read(data.get(), dataSize);
|
||||
if (!::UpdateResource(update, strType, stdstr(targetDir.GetNameExtension()).ToUpper().ToUTF16().c_str(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPVOID)data.get(), dataSize))
|
||||
{
|
||||
std::cout << "Error: Failed to UpdateResource on \"" << targetFile << "\"" << std::endl;
|
||||
targetFile.FileDelete();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: Failed to open \"" << targetDir << "\"" << std::endl;
|
||||
targetFile.FileDelete();
|
||||
return false;
|
||||
}
|
||||
|
||||
} while (targetDir.FindNext());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcessResource(const Path & sourceDir, const Path & targetFile, bool verbose)
|
||||
{
|
||||
{
|
||||
File targetResource;
|
||||
if (!targetResource.Open(targetFile, File::modeCreate | File::modeWrite))
|
||||
{
|
||||
std::cout << "Error: Failed to open \"" << targetFile << "\"" << std::endl;
|
||||
return false;
|
||||
}
|
||||
targetResource.Write(basedll, sizeof(basedll));
|
||||
targetResource.Close();
|
||||
}
|
||||
if (!ProcessDir(targetFile, sourceDir, "html", verbose))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!ProcessDir(targetFile, sourceDir, "image", verbose))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!ProcessDir(targetFile, sourceDir, "css", verbose))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
std::cout << "Usage: " << Path(argv[0]).GetNameExtension().c_str() << " <source_dir> <output_file>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
Path sourceDir(argv[1], "");
|
||||
sourceDir.DirectoryNormalize(Path(Path::MODULE_DIRECTORY));
|
||||
if (!sourceDir.DirectoryExists())
|
||||
{
|
||||
std::cout << "Error: Source directory does not exist" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
Path targetFile(argv[2]);
|
||||
if (!targetFile.DirectoryExists())
|
||||
{
|
||||
std::cout << "Error: Path for the file to be generated does not exist" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
bool verbose = argc > 3 && _stricmp(argv[3], "-v") == 0;
|
||||
return ProcessResource(sourceDir, targetFile, verbose);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{61b81f77-92c0-4c94-a893-7458fbe76c0b}</ProjectGuid>
|
||||
<RootNamespace>resourcepacker</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(SolutionDir)property_sheets\platform.$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="resource_packer.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="base_dll.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\sciterui\sciterui.vcxproj">
|
||||
<Project>{847b64ee-2c78-48f9-912b-d700f2a5cb91}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="resource_packer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="base_dll.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -14,7 +14,7 @@ void BaseElement::AddWidget(IWidget * widget)
|
||||
m_Widgets.push_back(widget);
|
||||
}
|
||||
|
||||
bool BaseElement::RemoveWidget(IWidget * widget)
|
||||
bool BaseElement::RemoveWidget(IWidget * /*widget*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
+23
-3
@@ -17,7 +17,7 @@ File::~File()
|
||||
}
|
||||
}
|
||||
|
||||
bool File::Open(const char* fileName, uint32_t openFlags)
|
||||
bool File::Open(const char * fileName, uint32_t openFlags)
|
||||
{
|
||||
if (!Close())
|
||||
{
|
||||
@@ -100,7 +100,7 @@ uint32_t File::GetLength() const
|
||||
return GetFileSize(m_file, &hiWord);
|
||||
}
|
||||
|
||||
uint32_t File::Read(void* lpBuf, uint32_t nCount)
|
||||
uint32_t File::Read(void * lpBuf, uint32_t nCount)
|
||||
{
|
||||
if (nCount == 0)
|
||||
{
|
||||
@@ -115,4 +115,24 @@ uint32_t File::Read(void* lpBuf, uint32_t nCount)
|
||||
return (uint32_t)read;
|
||||
}
|
||||
|
||||
}
|
||||
bool File::Write(const void * buffer, uint32_t bufferSize)
|
||||
{
|
||||
if (bufferSize == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
ULONG written = 0;
|
||||
if (!::WriteFile(m_file, buffer, bufferSize, &written, nullptr))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (written != bufferSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace SciterUI
|
||||
+9
-8
@@ -23,22 +23,23 @@ public:
|
||||
};
|
||||
|
||||
File();
|
||||
File(void* fileHandle);
|
||||
File(const char* fileName, uint32_t openFlags);
|
||||
File(void * fileHandle);
|
||||
File(const char * fileName, uint32_t openFlags);
|
||||
~File();
|
||||
|
||||
bool Open(const char* fileName, uint32_t openFlags);
|
||||
bool Open(const char * fileName, uint32_t openFlags);
|
||||
bool Close();
|
||||
|
||||
uint32_t GetLength() const;
|
||||
|
||||
uint32_t Read(void* buffer, uint32_t bufferSize);
|
||||
uint32_t Read(void * buffer, uint32_t bufferSize);
|
||||
bool Write(const void * buffer, uint32_t bufferSize);
|
||||
|
||||
private:
|
||||
File(const File&) = delete;
|
||||
File& operator=(const File&) = delete;
|
||||
File(const File &) = delete;
|
||||
File & operator=(const File &) = delete;
|
||||
|
||||
void* m_file;
|
||||
void * m_file;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace SciterUI
|
||||
@@ -26,4 +26,4 @@ private:
|
||||
Path m_path;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace SciterUI
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
namespace SciterUI
|
||||
{
|
||||
__interface IModuleResource
|
||||
{
|
||||
bool LoadResource(const wchar_t* name, const wchar_t* type, std::unique_ptr<uint8_t>& data, uint32_t& size);
|
||||
};
|
||||
}
|
||||
__interface IModuleResource
|
||||
{
|
||||
bool LoadResource(const wchar_t * name, const wchar_t * type, std::unique_ptr<uint8_t> & data, uint32_t & size);
|
||||
};
|
||||
} // namespace SciterUI
|
||||
+280
-1
@@ -2,6 +2,8 @@
|
||||
#include "std_string.h"
|
||||
#include <Windows.h>
|
||||
|
||||
#include <io.h>
|
||||
|
||||
namespace SciterUI
|
||||
{
|
||||
const char DRIVE_DELIMITER = ':';
|
||||
@@ -9,6 +11,9 @@ const char * const DIR_DOUBLEDELIM = "\\\\";
|
||||
const char DIRECTORY_DELIMITER = '\\';
|
||||
const char DIRECTORY_DELIMITER2 = '/';
|
||||
|
||||
const char EXTENSION_DELIMITER = '.';
|
||||
void * Path::m_hInst = nullptr;
|
||||
|
||||
Path::Path()
|
||||
{
|
||||
}
|
||||
@@ -25,6 +30,17 @@ Path::Path(const char * path, const char * fileName)
|
||||
SetNameExtension(fileName);
|
||||
}
|
||||
|
||||
Path::Path(DIR_MODULE_DIRECTORY /*sdt*/, const char * nameExten)
|
||||
{
|
||||
SetToModuleDirectory();
|
||||
SetNameExtension(nameExten ? nameExten : "");
|
||||
}
|
||||
|
||||
Path::~Path()
|
||||
{
|
||||
CloseFindHandle();
|
||||
}
|
||||
|
||||
Path::operator const char *() const
|
||||
{
|
||||
return (const char *)m_path.c_str();
|
||||
@@ -35,11 +51,68 @@ Path::operator const std::string &()
|
||||
return m_path;
|
||||
}
|
||||
|
||||
void Path::GetDriveDirectory(std::string & driveDirectory) const
|
||||
{
|
||||
std::string drive, directory;
|
||||
GetComponents(&drive, &directory);
|
||||
driveDirectory = drive;
|
||||
if (!drive.empty())
|
||||
{
|
||||
driveDirectory += DRIVE_DELIMITER;
|
||||
}
|
||||
driveDirectory += directory;
|
||||
}
|
||||
|
||||
std::string Path::GetDriveDirectory(void) const
|
||||
{
|
||||
std::string driveDirectory;
|
||||
GetDriveDirectory(driveDirectory);
|
||||
return driveDirectory;
|
||||
}
|
||||
|
||||
void Path::GetDirectory(std::string & directory) const
|
||||
{
|
||||
GetComponents(nullptr, &directory);
|
||||
}
|
||||
|
||||
std::string Path::GetDirectory(void) const
|
||||
{
|
||||
std::string directory;
|
||||
GetDirectory(directory);
|
||||
return directory;
|
||||
}
|
||||
|
||||
void Path::GetNameExtension(std::string & nameExtension) const
|
||||
{
|
||||
std::string name, extension;
|
||||
GetComponents(nullptr, nullptr, &name, &extension);
|
||||
nameExtension = name;
|
||||
if (!extension.empty())
|
||||
{
|
||||
nameExtension += EXTENSION_DELIMITER;
|
||||
nameExtension += extension;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Path::GetNameExtension(void) const
|
||||
{
|
||||
std::string nameExtension;
|
||||
GetNameExtension(nameExtension);
|
||||
return nameExtension;
|
||||
}
|
||||
|
||||
void Path::GetExtension(std::string & extension) const
|
||||
{
|
||||
GetComponents(nullptr, nullptr, nullptr, &extension);
|
||||
}
|
||||
|
||||
std::string Path::GetExtension(void) const
|
||||
{
|
||||
std::string extension;
|
||||
GetExtension(extension);
|
||||
return extension;
|
||||
}
|
||||
|
||||
void Path::GetComponents(std::string * drive, std::string * directory, std::string * name, std::string * extension) const
|
||||
{
|
||||
char driveBuff[_MAX_DRIVE + 1] = {0}, dirBuff[_MAX_DIR + 1] = {0}, nameBuff[_MAX_FNAME + 1] = {0}, extBuff[_MAX_EXT + 1] = {0};
|
||||
@@ -97,6 +170,19 @@ void Path::GetComponents(std::string * drive, std::string * directory, std::stri
|
||||
}
|
||||
}
|
||||
|
||||
bool Path::IsRelative() const
|
||||
{
|
||||
if (m_path.length() > 1 && m_path[1] == DRIVE_DELIMITER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_path.length() > 2 && m_path[0] == DIRECTORY_DELIMITER && m_path[1] == DIRECTORY_DELIMITER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Path::SetDriveDirectory(const char * driveDirectory)
|
||||
{
|
||||
std::string driveDirectoryStr = driveDirectory;
|
||||
@@ -167,6 +253,24 @@ void Path::AppendDirectory(const char * subDirectory)
|
||||
SetComponents(drive.c_str(), directory.c_str(), name.c_str(), extension.c_str());
|
||||
}
|
||||
|
||||
bool Path::FileDelete(bool evenIfReadOnly) const
|
||||
{
|
||||
std::wstring filePath = stdstr(m_path).ToUTF16();
|
||||
uint32_t attributes = ::GetFileAttributes(filePath.c_str());
|
||||
if (attributes == (uint32_t)-1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) && !evenIfReadOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SetFileAttributes(filePath.c_str(), FILE_ATTRIBUTE_NORMAL);
|
||||
return DeleteFile(filePath.c_str()) != 0;
|
||||
}
|
||||
|
||||
bool Path::FileExists() const
|
||||
{
|
||||
WIN32_FIND_DATA FindData;
|
||||
@@ -181,6 +285,13 @@ bool Path::FileExists() const
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
bool Path::IsDirectory() const
|
||||
{
|
||||
std::string fileName;
|
||||
GetNameExtension(fileName);
|
||||
return fileName.empty();
|
||||
}
|
||||
|
||||
bool Path::DirectoryExists() const
|
||||
{
|
||||
Path path(m_path.c_str());
|
||||
@@ -199,6 +310,46 @@ bool Path::DirectoryExists() const
|
||||
return res;
|
||||
}
|
||||
|
||||
Path & Path::DirectoryNormalize(Path BaseDir)
|
||||
{
|
||||
stdstr directory = BaseDir.GetDriveDirectory();
|
||||
bool changed = false;
|
||||
if (IsRelative())
|
||||
{
|
||||
EnsureTrailingBackslash(directory);
|
||||
directory += GetDirectory();
|
||||
changed = true;
|
||||
}
|
||||
strvector parts = directory.Tokenize(DIRECTORY_DELIMITER);
|
||||
strvector normalizesParts;
|
||||
for (strvector::const_iterator itr = parts.begin(); itr != parts.end(); itr++)
|
||||
{
|
||||
if (*itr == ".")
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
else if (*itr == "..")
|
||||
{
|
||||
normalizesParts.pop_back();
|
||||
changed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
normalizesParts.push_back(*itr);
|
||||
}
|
||||
}
|
||||
if (changed)
|
||||
{
|
||||
directory.clear();
|
||||
for (strvector::const_iterator itr = normalizesParts.begin(); itr != normalizesParts.end(); itr++)
|
||||
{
|
||||
directory += *itr + DIRECTORY_DELIMITER;
|
||||
}
|
||||
SetDriveDirectory(directory.c_str());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Path::DirectoryUp(std::string * lastDir)
|
||||
{
|
||||
std::string directory;
|
||||
@@ -222,6 +373,134 @@ void Path::DirectoryUp(std::string * lastDir)
|
||||
SetDirectory(directory.c_str());
|
||||
}
|
||||
|
||||
bool Path::FindFirst(uint32_t attributes)
|
||||
{
|
||||
CloseFindHandle();
|
||||
|
||||
m_findAttributes = attributes;
|
||||
bool bWantSubdirectory = (FIND_ATTRIBUTE_SUBDIR & attributes) != 0;
|
||||
|
||||
WIN32_FIND_DATA findData;
|
||||
m_findHandle = FindFirstFile(stdstr(m_path).ToUTF16().c_str(), &findData);
|
||||
bool foundFile = (m_findHandle != INVALID_HANDLE_VALUE);
|
||||
|
||||
if (m_findHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
m_findHandle = nullptr;
|
||||
}
|
||||
|
||||
while (foundFile)
|
||||
{
|
||||
if (AttributesMatch(m_findAttributes, findData.dwFileAttributes) &&
|
||||
(!bWantSubdirectory || (findData.cFileName[0] != '.')))
|
||||
{
|
||||
if ((FIND_ATTRIBUTE_SUBDIR & findData.dwFileAttributes) != 0)
|
||||
{
|
||||
StripTrailingBackslash(m_path);
|
||||
}
|
||||
SetNameExtension(stdstr().FromUTF16(findData.cFileName).c_str());
|
||||
if ((FIND_ATTRIBUTE_SUBDIR & findData.dwFileAttributes) != 0)
|
||||
{
|
||||
EnsureTrailingBackslash(m_path);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
foundFile = FindNextFile(m_findHandle, &findData);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Path::FindNext()
|
||||
{
|
||||
if (m_findHandle == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
WIN32_FIND_DATA FindData;
|
||||
while (FindNextFile(m_findHandle, &FindData) != false)
|
||||
{
|
||||
if (AttributesMatch(m_findAttributes, FindData.dwFileAttributes))
|
||||
{
|
||||
if ((_A_SUBDIR & FindData.dwFileAttributes) == _A_SUBDIR)
|
||||
{
|
||||
if (IsDirectory())
|
||||
{
|
||||
DirectoryUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNameExtension("");
|
||||
}
|
||||
AppendDirectory(stdstr().FromUTF16(FindData.cFileName).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsDirectory())
|
||||
{
|
||||
DirectoryUp();
|
||||
}
|
||||
SetNameExtension(stdstr().FromUTF16(FindData.cFileName).c_str());
|
||||
}
|
||||
if ((_A_SUBDIR & FindData.dwFileAttributes) == _A_SUBDIR)
|
||||
{
|
||||
EnsureTrailingBackslash(m_path);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Path::SetToModuleDirectory()
|
||||
{
|
||||
DWORD bufferSize = MAX_PATH;
|
||||
std::vector<wchar_t> buffPath(bufferSize);
|
||||
|
||||
while (true)
|
||||
{
|
||||
DWORD result = GetModuleFileNameW((HINSTANCE)m_hInst, buffPath.data(), bufferSize);
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
m_path = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (result < bufferSize)
|
||||
{
|
||||
m_path = stdstr().FromUTF16(buffPath.data());
|
||||
SetNameExtension("");
|
||||
return;
|
||||
}
|
||||
|
||||
bufferSize *= 2;
|
||||
buffPath.resize(bufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
bool Path::AttributesMatch(uint32_t targetAttributes, uint32_t fileAttributes)
|
||||
{
|
||||
if (targetAttributes == FIND_ATTRIBUTE_ALLFILES)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (targetAttributes == FIND_ATTRIBUTE_FILES)
|
||||
{
|
||||
return ((FIND_ATTRIBUTE_SUBDIR & fileAttributes) == 0);
|
||||
}
|
||||
return (((targetAttributes & fileAttributes) != 0) && ((FIND_ATTRIBUTE_SUBDIR & targetAttributes) == (FIND_ATTRIBUTE_SUBDIR & fileAttributes)));
|
||||
}
|
||||
|
||||
void Path::CloseFindHandle()
|
||||
{
|
||||
if (m_findHandle != nullptr)
|
||||
{
|
||||
FindClose(m_findHandle);
|
||||
m_findHandle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Path::CleanPath(std::string & path) const
|
||||
{
|
||||
std::string::size_type pos = path.find(DIRECTORY_DELIMITER2);
|
||||
@@ -294,4 +573,4 @@ void Path::StripTrailingBackslash(std::string & directory) const
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace SciterUI
|
||||
|
||||
+38
-1
@@ -7,15 +7,38 @@ namespace SciterUI
|
||||
class Path
|
||||
{
|
||||
public:
|
||||
enum DIR_MODULE_DIRECTORY
|
||||
{
|
||||
MODULE_DIRECTORY = 2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FIND_ATTRIBUTE_ALLFILES = 0xFFFF, // Search include all files
|
||||
FIND_ATTRIBUTE_FILES = 0x0000, // File can be read or written to without restriction
|
||||
FIND_ATTRIBUTE_SUBDIR = 0x0010, // Subdirectories
|
||||
};
|
||||
|
||||
Path();
|
||||
Path(const char * path);
|
||||
Path(const char * path, const char * fileName);
|
||||
|
||||
Path(DIR_MODULE_DIRECTORY sdt, const char * nameExten = nullptr);
|
||||
~Path();
|
||||
|
||||
operator const char *() const;
|
||||
operator const std::string &();
|
||||
|
||||
void GetDriveDirectory(std::string & directory) const;
|
||||
std::string GetDriveDirectory(void) const;
|
||||
void GetDirectory(std::string & directory) const;
|
||||
std::string GetDirectory(void) const;
|
||||
void GetNameExtension(std::string & nameExtension) const;
|
||||
std::string GetNameExtension(void) const;
|
||||
void GetExtension(std::string & rExtension) const;
|
||||
std::string GetExtension(void) const;
|
||||
void GetComponents(std::string * drive = nullptr, std::string * directory = nullptr, std::string * name = nullptr, std::string * extension = nullptr) const;
|
||||
bool IsRelative() const;
|
||||
|
||||
void SetDriveDirectory(const char * driveDirectory);
|
||||
void SetDirectory(const char * directory, bool ensureAbsolute = false);
|
||||
@@ -23,19 +46,33 @@ public:
|
||||
void SetComponents(const char * drive, const char * directory, const char * name, const char * extension);
|
||||
void AppendDirectory(const char * subDirectory);
|
||||
|
||||
bool FileDelete(bool evenIfReadOnly = true) const;
|
||||
bool FileExists() const;
|
||||
|
||||
bool IsDirectory() const;
|
||||
bool DirectoryExists() const;
|
||||
Path & DirectoryNormalize(Path baseDir);
|
||||
void DirectoryUp(std::string * lastDir = nullptr);
|
||||
|
||||
bool FindFirst(uint32_t attributes = 0);
|
||||
bool FindNext();
|
||||
|
||||
private:
|
||||
void SetToModuleDirectory();
|
||||
|
||||
bool AttributesMatch(uint32_t targetAttributes, uint32_t fileAttributes);
|
||||
void CloseFindHandle();
|
||||
|
||||
void CleanPath(std::string & path) const;
|
||||
void EnsureLeadingBackslash(std::string & directory) const;
|
||||
void EnsureTrailingBackslash(std::string & directory) const;
|
||||
void StripLeadingBackslash(std::string & path) const;
|
||||
void StripTrailingBackslash(std::string & rDirectory) const;
|
||||
|
||||
void * m_findHandle = nullptr;
|
||||
static void * m_hInst;
|
||||
std::string m_path;
|
||||
uint32_t m_findAttributes = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace SciterUI
|
||||
@@ -11,11 +11,11 @@ ResourceManager::ResourceManager(const char * languageDir) :
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"JPG", L"JPG"));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"GIF", L"GIF"));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"SVG", L"SVG"));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"BMP", (const wchar_t*)RT_BITMAP));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"ICO", (const wchar_t*)RT_GROUP_ICON));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"CUR", (const wchar_t*)RT_GROUP_CURSOR));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"HTM", (const wchar_t*)RT_HTML));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"HTML", (const wchar_t*)RT_HTML));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"BMP", (const wchar_t *)RT_BITMAP));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"ICO", (const wchar_t *)RT_GROUP_ICON));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"CUR", (const wchar_t *)RT_GROUP_CURSOR));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"HTM", (const wchar_t *)RT_HTML));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"HTML", (const wchar_t *)RT_HTML));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"CSS", L"CSS"));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"INI", L"LANG"));
|
||||
m_resourceMap.emplace(RESOURCE_MAP::value_type(L"LNG", L"LANG"));
|
||||
|
||||
@@ -99,7 +99,7 @@ bool Sciter::SetElementHtmlFromResource(SCITER_ELEMENT elemHandle, const char *
|
||||
uint32_t Size = 0;
|
||||
if (!m_resourceManager.LoadResource(stdstr(uri).ToUTF16().c_str(), Data, Size))
|
||||
{
|
||||
element.SetHTML((uint8_t*)"", 0, SciterElement::SIH_REPLACE_CONTENT);
|
||||
element.SetHTML((uint8_t *)"", 0, SciterElement::SIH_REPLACE_CONTENT);
|
||||
return false;
|
||||
}
|
||||
element.SetHTML(Data.get(), Size, SciterElement::SIH_REPLACE_CONTENT);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "std_string.h"
|
||||
#include <Windows.h>
|
||||
#include <algorithm>
|
||||
#include <stdarg.h>
|
||||
|
||||
namespace SciterUI
|
||||
@@ -24,6 +25,31 @@ stdstr::stdstr(const char * str) :
|
||||
{
|
||||
}
|
||||
|
||||
strvector stdstr::Tokenize(char delimiter) const
|
||||
{
|
||||
strvector tokens;
|
||||
|
||||
stdstr::size_type lastPos = find_first_not_of(delimiter, 0);
|
||||
stdstr::size_type pos = find_first_of(delimiter, lastPos);
|
||||
while (stdstr::npos != pos)
|
||||
{
|
||||
tokens.push_back(substr(lastPos, pos - lastPos));
|
||||
lastPos = pos + 1;
|
||||
pos = find_first_of(delimiter, lastPos);
|
||||
}
|
||||
if (stdstr::npos != lastPos)
|
||||
{
|
||||
tokens.push_back(substr(lastPos));
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
stdstr & stdstr::ToUpper(void)
|
||||
{
|
||||
std::transform(begin(), end(), begin(), (char (*)(int))toupper);
|
||||
return *this;
|
||||
}
|
||||
|
||||
stdstr & stdstr::Replace(const char search, const char replace)
|
||||
{
|
||||
std::string & str = *this;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace SciterUI
|
||||
{
|
||||
|
||||
class stdstr;
|
||||
typedef std::vector<stdstr> strvector;
|
||||
|
||||
class stdstr :
|
||||
public std::string
|
||||
{
|
||||
@@ -19,6 +23,9 @@ public:
|
||||
stdstr(const stdstr & str);
|
||||
stdstr(const char * str);
|
||||
|
||||
strvector Tokenize(char delimiter) const;
|
||||
stdstr & ToUpper(void);
|
||||
|
||||
stdstr & Replace(const char search, const char replace);
|
||||
stdstr & Replace(const char * search, const char replace);
|
||||
stdstr & Replace(const std::string & search, const std::string & replace);
|
||||
|
||||
@@ -73,7 +73,7 @@ void WidgetMenuBar::SetMenuContent(MenuBarItemList & items) const
|
||||
}
|
||||
html += "</ul>";
|
||||
impl->m_menuBarElem.SetHTML((const uint8_t *)html.data(), html.size(), SciterElement::SIH_REPLACE_CONTENT);
|
||||
impl->m_sciterUI.AttachHandler(impl->m_menuBarElem, IID_ICLICKSINK, (IClickSink*)this);
|
||||
impl->m_sciterUI.AttachHandler(impl->m_menuBarElem, IID_ICLICKSINK, (IClickSink *)this);
|
||||
}
|
||||
|
||||
void WidgetMenuBar::AddSink(IMenuBarSink * sink)
|
||||
|
||||
Reference in New Issue
Block a user