access to the file is OK in the memory
This commit is contained in:
parent
ac984dac7a
commit
8d7a9bedfa
2
Makefile
2
Makefile
@ -307,7 +307,7 @@ fileToCpp: tools/fileToCpp.cpp
|
||||
$(FILE_DIRECTORY)/GeneratedData.cpp: $(DATA_FILE) $(MAKE_DEPENDENCE) fileToCpp
|
||||
@echo $(F_BLUE)" (.cpp) "$(DATA_FOLDER)" ==> $@"$(F_NORMALE)
|
||||
@#echo ./pngToCpp $@ $(DATA_FILE)
|
||||
@./fileToCpp $@ $(DATA_FILE)
|
||||
./fileToCpp $@ $(DATA_FILE)
|
||||
|
||||
|
||||
.versionFile:
|
||||
|
@ -147,10 +147,11 @@ extern "C"
|
||||
{
|
||||
case 0:
|
||||
EWOL_WARNING("Directory mode=FILE path=" << str);
|
||||
etk::SetBaseFolder(str);
|
||||
etk::SetBaseFolderData(str);
|
||||
break;
|
||||
case 1:
|
||||
EWOL_WARNING("Directory mode=CACHE path=" << str);
|
||||
etk::SetBaseFolderCache(str);
|
||||
break;
|
||||
case 2:
|
||||
EWOL_WARNING("Directory mode=EXTERNAL_CACHE path=" << str);
|
||||
@ -163,7 +164,6 @@ extern "C"
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool isAlreadyInit = false;
|
||||
|
||||
void Java_com_example_ewolAbstraction_EwolGLSurfaceView_nativeApplicationInit( JNIEnv* env)
|
||||
|
@ -164,7 +164,13 @@ etk::String baseFolderCache = "~/.tmp/cache";
|
||||
// for specific device contraint :
|
||||
void etk::SetBaseFolderData(const char * folder)
|
||||
{
|
||||
baseFolderData = folder;
|
||||
#ifdef DATA_INTERNAL_BINARY
|
||||
for(int32_t iii=0; iii<internalDataFilesSize; iii++) {
|
||||
TK_DEBUG("Internal date : \"" << internalDataFiles[iii].filename << "\" size=" << internalDataFiles[iii].fileLenght);
|
||||
}
|
||||
#else
|
||||
baseFolderData = folder;
|
||||
#endif
|
||||
}
|
||||
void etk::SetBaseFolderDataUser(const char * folder)
|
||||
{
|
||||
@ -416,7 +422,7 @@ bool etk::File::fOpenRead(void)
|
||||
if (etk::FILE_TYPE_DATA == m_type) {
|
||||
m_readingOffset = 0;
|
||||
if (m_idInternal >= -1 && m_idInternal < internalDataFilesSize) {
|
||||
TK_DEBUG("Open file : " << GetCompleateName() << " with size=" << internalDataFilesSize << " Octets");
|
||||
TK_DEBUG("Open file : " << GetCompleateName() << " with size=" << internalDataFiles[m_idInternal].fileLenght << " Octets");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -478,11 +484,12 @@ char * etk::File::fGets(char * elementLine, int32_t maxData)
|
||||
{
|
||||
#ifdef DATA_INTERNAL_BINARY
|
||||
char * element = elementLine;
|
||||
memset(elementLine, 0, maxData);
|
||||
if (etk::FILE_TYPE_DATA == m_type) {
|
||||
if (m_idInternal >= -1 && m_idInternal < internalDataFilesSize) {
|
||||
// TODO ...
|
||||
//char * tmpData = internalDataFiles[iii].data + m_readingOffset;
|
||||
if (m_readingOffset>internalDataFilesSize) {
|
||||
if (m_readingOffset>internalDataFiles[m_idInternal].fileLenght) {
|
||||
element[0] = '\0';
|
||||
return NULL;
|
||||
}
|
||||
@ -500,12 +507,13 @@ char * etk::File::fGets(char * elementLine, int32_t maxData)
|
||||
element++;
|
||||
m_readingOffset++;
|
||||
// TODO : Understand why this does not work
|
||||
/*if (m_readingOffset>internalDataFilesSize) {
|
||||
if (m_readingOffset>internalDataFiles[m_idInternal].fileLenght) {
|
||||
*element = '\0';
|
||||
return elementLine;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
elementLine[0] = '\0';
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@ -518,8 +526,8 @@ int32_t etk::File::fRead(void * data, int32_t blockSize, int32_t nbBlock)
|
||||
if (etk::FILE_TYPE_DATA == m_type) {
|
||||
if (m_idInternal >= -1 && m_idInternal < internalDataFilesSize) {
|
||||
int32_t dataToRead = blockSize * nbBlock;
|
||||
if (dataToRead + m_readingOffset > internalDataFilesSize) {
|
||||
nbBlock = ((internalDataFilesSize - m_readingOffset) / blockSize);
|
||||
if (dataToRead + m_readingOffset > internalDataFiles[m_idInternal].fileLenght) {
|
||||
nbBlock = ((internalDataFiles[m_idInternal].fileLenght - m_readingOffset) / blockSize);
|
||||
dataToRead = blockSize * nbBlock;
|
||||
}
|
||||
memcpy(data, &internalDataFiles[m_idInternal].data[m_readingOffset], dataToRead);
|
||||
@ -544,6 +552,39 @@ int32_t etk::File::fWrite(void * data, int32_t blockSize, int32_t nbBlock)
|
||||
}
|
||||
|
||||
|
||||
bool etk::File::fSeek(long int offset, int origin)
|
||||
{
|
||||
#ifdef DATA_INTERNAL_BINARY
|
||||
if (etk::FILE_TYPE_DATA == m_type) {
|
||||
if (m_idInternal >= -1 && m_idInternal < internalDataFilesSize) {
|
||||
int32_t positionEnd = 0;
|
||||
switch(origin) {
|
||||
case SEEK_END:
|
||||
positionEnd = internalDataFiles[m_idInternal].fileLenght;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
positionEnd = m_readingOffset;
|
||||
break;
|
||||
default:
|
||||
positionEnd = 0;
|
||||
break;
|
||||
}
|
||||
positionEnd += offset;
|
||||
if (positionEnd < 0) {
|
||||
positionEnd = 0;
|
||||
} else if (positionEnd > internalDataFiles[m_idInternal].fileLenght) {
|
||||
positionEnd = internalDataFiles[m_idInternal].fileLenght;
|
||||
}
|
||||
m_readingOffset = positionEnd;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return fseek(m_PointerFile, offset, origin);
|
||||
}
|
||||
|
||||
|
||||
char * etk::File::GetDirectPointer(void)
|
||||
{
|
||||
#ifdef DATA_INTERNAL_BINARY
|
||||
|
@ -90,6 +90,7 @@ namespace etk
|
||||
char * fGets(char * elementLine, int32_t maxData);
|
||||
int32_t fRead(void * data, int32_t blockSize, int32_t nbBlock);
|
||||
int32_t fWrite(void * data, int32_t blockSize, int32_t nbBlock);
|
||||
bool fSeek(long int offset, int origin);
|
||||
private :
|
||||
etk::FileType_te m_type;
|
||||
FILE * m_PointerFile;
|
||||
|
@ -76,7 +76,7 @@ namespace ewol
|
||||
int32_t lineID=1;
|
||||
while (NULL != m_filename.fGets(elementLine, 2048) )
|
||||
{
|
||||
EWOL_DEBUG(" Read file Line : " << elementLine);
|
||||
//EWOL_DEBUG(" Read file Line : " << elementLine);
|
||||
if ( '\n' != elementLine[0] // EOL
|
||||
&& '\0' != elementLine[0] // EOF
|
||||
&& '#' != elementLine[0] // Comment line
|
||||
|
@ -86,44 +86,40 @@ class Bitmap
|
||||
m_height = 0;
|
||||
m_size = 0;
|
||||
|
||||
FILE *File=NULL;
|
||||
// Get the fileSize ...
|
||||
/*if (fileName.Size() < (int32_t)(sizeof(bitmapFileHeader_ts) + sizeof(bitmapInfoHeader_ts) ) ) {
|
||||
EWOL_ERROR("not enought data in the file named=\"" << fileName << "\"");
|
||||
return;
|
||||
}*/
|
||||
File=fopen(fileName.GetCompleateName().c_str(),"rb");
|
||||
if(NULL == File) {
|
||||
if(false == fileName.fOpenRead() ) {
|
||||
EWOL_ERROR("Can not find the file name=\"" << fileName << "\"");
|
||||
return;
|
||||
}
|
||||
// get the data :
|
||||
if (fread(&m_FileHeader,sizeof(bitmapFileHeader_ts),1,File) != 1) {
|
||||
if (fileName.fRead(&m_FileHeader,sizeof(bitmapFileHeader_ts),1) != 1) {
|
||||
EWOL_ERROR("error loading file header");
|
||||
fclose(File);
|
||||
fileName.fClose();
|
||||
return;
|
||||
}
|
||||
if (fread(&m_InfoHeader,sizeof(bitmapInfoHeader_ts),1,File) != 1) {
|
||||
if (fileName.fRead(&m_InfoHeader,sizeof(bitmapInfoHeader_ts),1) != 1) {
|
||||
EWOL_ERROR("error loading file header");
|
||||
fclose(File);
|
||||
fileName.fClose();
|
||||
return;
|
||||
}
|
||||
// TODO : do otherwise ...
|
||||
fseek(File,m_FileHeader.bfOffBits,SEEK_SET);
|
||||
if(ferror(File)) {
|
||||
if(false == fileName.fSeek(m_FileHeader.bfOffBits, SEEK_SET)) {
|
||||
EWOL_ERROR("error with the 'bfOffBits' in the file named=\"" << fileName << "\"");
|
||||
fclose(File);
|
||||
fileName.fClose();
|
||||
return;
|
||||
}
|
||||
// Check the header error :
|
||||
if (m_FileHeader.bfType != 0x4D42) {
|
||||
EWOL_ERROR("the file=\"" << fileName << "\" is not a bitmap file ...");
|
||||
fclose(File);
|
||||
fileName.fClose();
|
||||
return;
|
||||
}
|
||||
if (m_FileHeader.bfReserved != 0x00000000) {
|
||||
EWOL_ERROR("the bfReserved feald is not at 0 ==> not supported format ...");
|
||||
fclose(File);
|
||||
fileName.fClose();
|
||||
return;
|
||||
}
|
||||
if( m_InfoHeader.biBitCount == 16
|
||||
@ -148,7 +144,7 @@ class Bitmap
|
||||
m_dataMode = BITS_32_A8R8G8B8;
|
||||
} else {
|
||||
EWOL_ERROR("the biBitCount & biCompression fealds are unknow ==> not supported format ...");
|
||||
fclose(File);
|
||||
fileName.fClose();;
|
||||
return;
|
||||
}
|
||||
m_width = m_InfoHeader.biWidth;
|
||||
@ -157,13 +153,13 @@ class Bitmap
|
||||
if(0 != m_InfoHeader.biSizeImage)
|
||||
{
|
||||
m_data=new uint8_t[m_InfoHeader.biSizeImage];
|
||||
if (fread(m_data,m_InfoHeader.biSizeImage,1,File) != 1){
|
||||
if (fileName.fRead(m_data,m_InfoHeader.biSizeImage,1) != 1){
|
||||
EWOL_CRITICAL("Can not read the file with the good size...");
|
||||
}
|
||||
// allocate the destination data ...
|
||||
m_dataGenerate=new uint8_t[m_width*m_height*4];
|
||||
}
|
||||
fclose(File);
|
||||
fileName.fClose();
|
||||
// need now to generate RGBA data ...
|
||||
switch(m_dataMode)
|
||||
{
|
||||
@ -358,8 +354,11 @@ int32_t ewol::LoadTexture(etk::File fileName)
|
||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
//--- Mode linear
|
||||
|
||||
#ifdef __PLATFORM__X11
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myBitmap.Width(), myBitmap.Height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, myBitmap.Data());
|
||||
LoadedTexture *tmpTex = new LoadedTexture();
|
||||
if (NULL != tmpTex) {
|
||||
|
@ -93,14 +93,14 @@ void ewol::GetAbsPos(int32_t & x, int32_t & y)
|
||||
|
||||
void ewol::StartResizeSystem(void)
|
||||
{
|
||||
#if __PLATFORM__ == X11
|
||||
#ifdef __PLATFORM__X11
|
||||
guiAbstraction::StartResizeSystem();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ewol::StartMoveSystem(void)
|
||||
{
|
||||
#if __PLATFORM__ == X11
|
||||
#ifdef __PLATFORM__X11
|
||||
guiAbstraction::StartMoveSystem();
|
||||
#endif
|
||||
}
|
||||
|
@ -14,8 +14,10 @@ LOCAL_CFLAGS := -D__PLATFORM__Android \
|
||||
-DEWOL_DEBUG_LEVEL=3 \
|
||||
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
|
||||
-DVERSION_BUILD_TIME="\"pasd_heure\"" \
|
||||
-DDATA_INTERNAL_BINARY
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
../Sources/GeneratedData.cpp \
|
||||
../Sources/Main.cpp \
|
||||
../Sources/base/guiAndroid.cpp \
|
||||
../Sources/tinyXML/tinyxml.cpp \
|
||||
|
@ -115,13 +115,14 @@ void process(const char *ifname)
|
||||
fprintf(ofile, "0x%02x,", c);
|
||||
n++;
|
||||
}
|
||||
|
||||
fprintf(ofile, "\n\t\t0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00");
|
||||
fprintf(ofile, "\n};\n");
|
||||
fprintf(ofile, "long int %s_size = sizeof(%s);\n", buf, buf);
|
||||
|
||||
//fprintf(ofileH, "extern unsigned char %s[];\n", buf);
|
||||
//fprintf(ofileH, "extern unsigned long int %s_size;\n", buf);
|
||||
char tmpVar[4096];
|
||||
sprintf(tmpVar, " {\"%s\", %s_size , %s},\n", ifname, buf, buf);
|
||||
sprintf(tmpVar, " {\"%s\", %d , %s},\n", ifname, n, buf);
|
||||
strcat (endTable, tmpVar);
|
||||
|
||||
fclose(ifile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user