moved files to trunk directory
git-svn-id: svn://anubis/dwscr/trunk@83 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
1 parent
78092ee118
commit
68d41e9c63
26 files changed
+2184
No files matched your search
@@ -0,0 +1,42 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "LoadFile.h"
|
||||
|
||||
typedef struct {
|
||||
const char * filename;
|
||||
unsigned char * data;
|
||||
int length;
|
||||
} fileref_t;
|
||||
|
||||
/* The data section is generated by a perl script. The contents of the
|
||||
* included file are part of this logical program unit, which is why it
|
||||
* is directly included instead of compiling it separately.
|
||||
*/
|
||||
#include "LoadFile-gen.inc"
|
||||
|
||||
const static int numFiles = sizeof(LoadFileData)/sizeof(fileref_t);
|
||||
|
||||
static std::map< std::string, fileref_t * > * LoadFileMap = NULL;
|
||||
|
||||
void * LoadFile(const char * filename, unsigned int * length)
|
||||
{
|
||||
if (LoadFileMap == NULL)
|
||||
{
|
||||
LoadFileMap = new std::map< std::string, fileref_t * >();
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
{
|
||||
(*LoadFileMap)[std::string(LoadFileData[i].filename)] = &LoadFileData[i];
|
||||
}
|
||||
}
|
||||
|
||||
std::map< std::string, fileref_t * >::iterator it =
|
||||
LoadFileMap->find(std::string(filename));
|
||||
|
||||
if (it == LoadFileMap->end())
|
||||
return NULL;
|
||||
|
||||
*length = it->second->length;
|
||||
return it->second->data;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
void * LoadFile(const char * filename, unsigned int * length);
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
GENLOADFILE := perl genLoadFile.pl
|
||||
LOGO_PATH := ../logo
|
||||
LOADFILES += dwlogo.obj
|
||||
LOADFILES += dwlogo.mtl
|
||||
ABSLOADFILES := $(foreach lf,$(LOADFILES),$(LOGO_PATH)/$(lf))
|
||||
|
||||
all: LoadFile.o
|
||||
|
||||
LoadFile.o: LoadFile.cc LoadFile-gen.inc
|
||||
$(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS)
|
||||
|
||||
LoadFile-gen.inc: genLoadFile.pl $(ABSLOADFILES)
|
||||
$(GENLOADFILE) --root=$(LOGO_PATH) $(LOADFILES)
|
||||
|
||||
clean:
|
||||
-$(RM) -f *~ *.o LoadFile-gen.inc
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
|
||||
my $root = '.';
|
||||
GetOptions('root=s' => \$root);
|
||||
|
||||
my @fileList = @ARGV;
|
||||
if ($#fileList < 0)
|
||||
{
|
||||
print "$0 <fileList>\n";
|
||||
exit(42);
|
||||
}
|
||||
|
||||
my %fileData;
|
||||
my $index = 0;
|
||||
|
||||
open(OUTPUT, '>', 'LoadFile-gen.inc');
|
||||
chdir($root);
|
||||
foreach my $fileName (@fileList)
|
||||
{
|
||||
local $/;
|
||||
open(FILE, '<', $fileName);
|
||||
my $fileContents = <FILE>;
|
||||
close(FILE);
|
||||
my $length = length($fileContents);
|
||||
my @fileContents = split(//, $fileContents);
|
||||
my $cname = "dat$index";
|
||||
print OUTPUT "\nstatic unsigned char ${cname}[] = {\n";
|
||||
for (my $byteNum = 0; $byteNum <= $#fileContents; $byteNum++)
|
||||
{
|
||||
print OUTPUT " " if ($byteNum % 12 == 0);
|
||||
printf OUTPUT ("0x%02x", ord($fileContents[$byteNum]));
|
||||
print OUTPUT ", " unless ($byteNum == $#fileContents);
|
||||
print OUTPUT "\n" if ($byteNum % 12 == 11);
|
||||
}
|
||||
print OUTPUT "\n};\n";
|
||||
$index++;
|
||||
$fileData{$fileName} = [$cname, $length];
|
||||
}
|
||||
|
||||
print OUTPUT "\nfileref_t LoadFileData[] = {\n";
|
||||
|
||||
my @fileNames = keys(%fileData);
|
||||
for (my $fileIndex = 0; $fileIndex <= $#fileNames; $fileIndex++)
|
||||
{
|
||||
my $fileName = $fileNames[$fileIndex];
|
||||
printf OUTPUT (' {"%s", %s, %s}',
|
||||
$fileName,
|
||||
$fileData{$fileName}->[0],
|
||||
$fileData{$fileName}->[1]);
|
||||
print OUTPUT "," unless ($fileIndex == $#fileNames);
|
||||
print OUTPUT "\n";
|
||||
}
|
||||
print OUTPUT "};\n";
|
||||
close(OUTPUT);
|
||||
Reference in new issue
Block a user