diff --git a/Makefile b/Makefile index 6d1228f2..2eb4e6db 100644 --- a/Makefile +++ b/Makefile @@ -49,18 +49,24 @@ DEFAULT_PLATFORM=X11 # default platform can be overridden PLATFORM?=$(DEFAULT_PLATFORM) +DATA_MODE=MEMORY + ifeq ($(PLATFORM), X11) CXXFILES += base/guiX11.cpp else ifeq ($(PLATFORM), DoubleBuffer) CXXFILES += base/guiDoubleBuffer.cpp else ifeq ($(PLATFORM), IPhone) CXXFILES += base/guiIPhone.cpp + DATA_MODE=MEMORY else ifeq ($(PLATFORM), IPad) CXXFILES += base/guiIPad.cpp + DATA_MODE=MEMORY else ifeq ($(PLATFORM), Android) CXXFILES += base/guiAndroid.cpp + DATA_MODE=MEMORY else ifeq ($(PLATFORM), AndroidTablet) CXXFILES += base/guiAndroidTablet.cpp + DATA_MODE=MEMORY else $(error you must specify a corect platform : make PLATFORM=$(SUPPORTED_PLATFORM)) endif @@ -139,6 +145,10 @@ CXXFLAGS+= -D_REENTRANT CXXFLAGS+= $(DEFINE) # remove warning from the convertion char* CXXFLAGS+= -Wno-write-strings +#set data in memory +ifeq ($(DATA_MODE), MEMORY) +CXXFLAGS+= -DDATA_INTERNAL_BINARY +endif CFLAGS= $(CXXFLAGS) -std=c99 @@ -180,6 +190,12 @@ MAKE_DEPENDENCE=Makefile ### Files Listes ### ############################################################################### +#data File of the program : +ifeq ($(DATA_MODE), MEMORY) +CXXFILES += GeneratedData.cpp +endif + + # tiny XML (extern OPEN Sources) : CXXFILES += tinyXML/tinyxml.cpp \ tinyXML/tinyxmlparser.cpp \ @@ -236,10 +252,13 @@ CXXFILES += ewol/themeManager.cpp \ + # Ewol Test Software : CXXFILES += Main.cpp - +# get all data file in the specific folder +DATA_FOLDER=dataTest +DATA_FILE=$(shell find $(DATA_FOLDER)/*) ############################################################################### ### Liste of folder where .h can be ### @@ -278,6 +297,19 @@ build: .encadrer .versionFile $(OUTPUT_NAME) @mkdir -p $(addprefix $(OBJECT_DIRECTORY)/, $(LISTE_MODULES)) +# Tool used to create a binary version of every element png or other needed by the application +fileToCpp: tools/fileToCpp.cpp + @echo $(F_ROUGE)" (bin) $@"$(F_NORMALE) + @$(CXX) $< -o $@ + @strip -s $@ + +# Generate basic user Data +$(FILE_DIRECTORY)/GeneratedData.cpp: $(DATA_FILE) $(MAKE_DEPENDENCE) fileToCpp + @echo $(F_BLUE)" (.cpp) "$(DATA_FOLDER)" ==> $@"$(F_NORMALE) + @#echo ./pngToCpp $@ $(DATA_FILE) + @./fileToCpp $@ $(DATA_FILE) + + .versionFile: @rm -f $(OBJECT_DIRECTORY)/ewol/ewol.o diff --git a/Sources/Main.cpp b/Sources/Main.cpp index 563a9e1e..0dca7664 100644 --- a/Sources/Main.cpp +++ b/Sources/Main.cpp @@ -100,12 +100,13 @@ void APP_Init(int argc, char *argv[]) //fontID = GetFontIdWithFileName("dataTest/TextMonospace.ebt"); } */ - ewol::SetFontFolder("Font"); + ewol::SetFontFolder("dataTest/Font"); //ewol::SetDefaultFont("freefont/FreeMono", 14); ewol::SetDefaultFont("ebtfont/Monospace", 14); //ewol::theme::LoadDefault("dataTest/exemple.eol"); - ewol::theme::LoadDefault("theme/exemple.eol"); - + etk::File fileTmp("dataTest/exemple.eol", etk::FILE_TYPE_DATA); + ewol::theme::LoadDefault(fileTmp); + /* etk::File tmpFile("/data/data/com.example.EwolActivity.app/assets/theme/exemple.eol"); if (tmpFile.Exist() ) { EWOL_WARNING("file existed : " << tmpFile); @@ -138,7 +139,7 @@ void APP_Init(int argc, char *argv[]) if (tmpFile.Exist() ) { EWOL_WARNING("file existed : " << tmpFile); } - + */ myWindowsExample = new Plop(); diff --git a/Sources/etk/File.cpp b/Sources/etk/File.cpp index e2b7e6db..14bac61d 100644 --- a/Sources/etk/File.cpp +++ b/Sources/etk/File.cpp @@ -28,6 +28,12 @@ #include #include +#ifdef DATA_INTERNAL_BINARY +# include "GeneratedData.h" +#endif + + + #undef __class__ #define __class__ "etk::File" @@ -40,33 +46,40 @@ etk::CCout& etk::operator <<(etk::CCout &os, const etk::File &obj) return os; } -etk::File::File(etk::String &filename, int32_t LineNumber) +etk::File::File(etk::String &filename, etk::FileType_te type, int32_t LineNumber) { m_lineNumberOpen = LineNumber; - SetCompleateName(filename); + m_PointerFile = NULL; + SetCompleateName(filename, type); } -etk::File::File(const char *filename, int32_t LineNumber) +etk::File::File(const char *filename, etk::FileType_te type, int32_t LineNumber) { etk::String tmpString = filename; m_lineNumberOpen = LineNumber; - SetCompleateName(tmpString); + m_PointerFile = NULL; + SetCompleateName(tmpString, type); } -etk::File::File(etk::String &filename, etk::String &folder, int32_t lineNumber) +etk::File::File(etk::String &filename, etk::String &folder, etk::FileType_te type, int32_t lineNumber) { etk::String tmpString = folder; tmpString += '/'; tmpString += filename; - SetCompleateName(tmpString); + m_PointerFile = NULL; + SetCompleateName(tmpString, type); m_lineNumberOpen = lineNumber; } etk::File::~File(void) { // nothing to do ... + if (NULL != m_PointerFile) { + TK_ERROR("Missing close the file : \"" << GetCompleateName() << "\""); + fClose(); + } } @@ -96,6 +109,15 @@ const etk::File& etk::File::operator= (const etk::File &etkF ) m_folder = etkF.m_folder; m_shortFilename = etkF.m_shortFilename; m_lineNumberOpen = etkF.m_lineNumberOpen; + m_type = etkF.m_type; + if (NULL != m_PointerFile) { + TK_ERROR("Missing close the file : \"" << GetCompleateName() << "\""); + fClose(); + } + #ifdef DATA_INTERNAL_BINARY + m_idInternal = etkF.m_idInternal; + m_readingOffset = 0; + #endif } return *this; } @@ -136,20 +158,32 @@ bool etk::File::operator!= (const etk::File &etkF) const } -etk::String baseFolderMobile = "/data/data/com.example.ewolAbstraction/assets/"; +etk::String baseFolderData = "./"; +etk::String baseFolderDataUser = "~/.tmp/userData"; +etk::String baseFolderCache = "~/.tmp/cache"; // for specific device contraint : -void etk::SetBaseFolder(const char * folder) +void etk::SetBaseFolderData(const char * folder) { - //baseFolderMobile = folder; + baseFolderData = folder; +} +void etk::SetBaseFolderDataUser(const char * folder) +{ + baseFolderDataUser = folder; +} +void etk::SetBaseFolderCache(const char * folder) +{ + baseFolderCache = folder; } - -void etk::File::SetCompleateName(etk::String &newFilename) +void etk::File::SetCompleateName(etk::String &newFilename, etk::FileType_te type) { char buf[MAX_FILE_NAME]; memset(buf, 0, MAX_FILE_NAME); char * ok; + #ifdef DATA_INTERNAL_BINARY + m_idInternal = -1; + #endif // Reset ALL DATA : m_folder = ""; m_shortFilename = ""; @@ -162,50 +196,119 @@ void etk::File::SetCompleateName(etk::String &newFilename) destFilename = newFilename; } TK_VERBOSE("2 : Get file Name : " << destFilename ); - if ('/' != *destFilename.c_str()) { - // Get the command came from the running of the program : - char cCurrentPath[FILENAME_MAX]; - #ifdef __PLATFORM__Android - strcpy(cCurrentPath, baseFolderMobile.c_str() ); - #else - if (!getcwd(cCurrentPath, FILENAME_MAX)) { - return; - } - #endif - cCurrentPath[FILENAME_MAX - 1] = '\0'; - etk::String tmpFilename = destFilename; - destFilename = cCurrentPath; - destFilename += '/'; - destFilename += tmpFilename; - } - TK_VERBOSE("3 : Get file Name : " << destFilename ); - - // Get the real Path of the current File - ok = realpath(destFilename.c_str(), buf); - if (!ok) { - int32_t lastPos = destFilename.FindBack('/'); - if (-1 != lastPos) { - // Get the FileName - etk::String tmpFilename = destFilename.Extract(lastPos+1); - destFilename.Remove(lastPos, destFilename.Size() - lastPos); - TK_VERBOSE("try to find :\"" << destFilename << "\" / \"" << tmpFilename << "\" "); - ok = realpath(destFilename.c_str(), buf); - if (!ok) { - TK_VERBOSE("Can not find real Path name of \"" << destFilename << "\""); - m_shortFilename = tmpFilename; - m_folder = destFilename; - } else { - // ALL is OK ... - m_shortFilename = tmpFilename; - m_folder = destFilename; - } - } else { - TK_WARNING("file : \"" << destFilename << "\" ==> No data???"); - // Basic ERROR ... - m_shortFilename = destFilename; + if ('/' == *destFilename.c_str()) { + m_type = etk::FILE_TYPE_DIRECT; + if (type != etk::FILE_TYPE_DIRECT) { + TK_WARNING("Incompatible type with a file=\"" << newFilename << "\" ==> force it in direct mode ..."); + } + } else { + if (type == etk::FILE_TYPE_DIRECT) { + TK_WARNING("Incompatible type with a file=\"" << newFilename << "\" ==> force it in FILE_TYPE_DATA mode ..."); + m_type = etk::FILE_TYPE_DATA; + } else { + m_type = type; + } + } + bool needUnpack = false; + #if ETK_DEBUG_LEVEL > 3 + char *mode = NULL; + #endif + switch (m_type) + { + case etk::FILE_TYPE_DATA: + { + #if ETK_DEBUG_LEVEL > 3 + mode = "FILE_TYPE_DATA"; + #endif + #ifdef DATA_INTERNAL_BINARY + for(int32_t iii=0; iii 3 + mode = "FILE_TYPE_USER_DATA"; + #endif + etk::String tmpFilename = destFilename; + destFilename = baseFolderDataUser; + destFilename += '/'; + destFilename += tmpFilename; + } + needUnpack = true; + break; + case etk::FILE_TYPE_CACHE: + { + #if ETK_DEBUG_LEVEL > 3 + mode = "FILE_TYPE_CACHE"; + #endif + etk::String tmpFilename = destFilename; + destFilename = baseFolderCache; + destFilename += '/'; + destFilename += tmpFilename; + } + needUnpack = true; + break; + default: + // nothing to do ... + #if ETK_DEBUG_LEVEL > 3 + mode = "FILE_TYPE_DIRECT"; + #endif + needUnpack = true; + break; + } + TK_VERBOSE("3 : Get file Name : " << destFilename ); + if (true == needUnpack) { + // Get the real Path of the current File + ok = realpath(destFilename.c_str(), buf); + if (!ok) { + int32_t lastPos = destFilename.FindBack('/'); + if (-1 != lastPos) { + // Get the FileName + etk::String tmpFilename = destFilename.Extract(lastPos+1); + destFilename.Remove(lastPos, destFilename.Size() - lastPos); + TK_VERBOSE("try to find :\"" << destFilename << "\" / \"" << tmpFilename << "\" "); + ok = realpath(destFilename.c_str(), buf); + if (!ok) { + TK_VERBOSE("Can not find real Path name of \"" << destFilename << "\""); + m_shortFilename = tmpFilename; + m_folder = destFilename; + } else { + // ALL is OK ... + m_shortFilename = tmpFilename; + m_folder = destFilename; + } + } else { + TK_WARNING("file : \"" << destFilename << "\" ==> No data???"); + // Basic ERROR ... + m_shortFilename = destFilename; + } + } else { + destFilename = buf; + int32_t lastPos = destFilename.FindBack('/'); + if (-1 != lastPos) { + m_shortFilename = destFilename.Extract(lastPos+1); + m_folder = destFilename.Extract(0, lastPos); + } else { + // Basic ERROR ... + TK_WARNING("file : \"" << destFilename << "\" ==> No data???"); + m_shortFilename = destFilename; + } } } else { - destFilename = buf; int32_t lastPos = destFilename.FindBack('/'); if (-1 != lastPos) { m_shortFilename = destFilename.Extract(lastPos+1); @@ -216,7 +319,7 @@ void etk::File::SetCompleateName(etk::String &newFilename) m_shortFilename = destFilename; } } - TK_VERBOSE("Set FileName :\"" << m_folder << "\" / \"" << m_shortFilename << "\" "); + TK_VERBOSE("Set FileName :\"" << m_folder << "\" / \"" << m_shortFilename << "\" mode=" << mode); } int32_t etk::File::GetLineNumber(void) @@ -261,6 +364,14 @@ etk::String etk::File::GetExtention(void) int32_t etk::File::Size(void) { + #ifdef DATA_INTERNAL_BINARY + if (etk::FILE_TYPE_DATA == m_type) { + if (m_idInternal >= -1 && m_idInternal < internalDataFilesSize) { + return internalDataFiles[m_idInternal].fileLenght; + } + return 0; + } + #endif FILE *myFile=NULL; etk::String myCompleateName = GetCompleateName(); myFile=fopen(myCompleateName.c_str(),"rb"); @@ -279,6 +390,14 @@ int32_t etk::File::Size(void) bool etk::File::Exist(void) { + #ifdef DATA_INTERNAL_BINARY + if (etk::FILE_TYPE_DATA == m_type) { + if (m_idInternal >= -1 && m_idInternal < internalDataFilesSize) { + return true; + } + return false; + } + #endif FILE *myFile=NULL; etk::String myCompleateName = GetCompleateName(); myFile=fopen(myCompleateName.c_str(),"rb"); @@ -288,3 +407,151 @@ bool etk::File::Exist(void) fclose(myFile); return true; } + + + +bool etk::File::fOpenRead(void) +{ + #ifdef DATA_INTERNAL_BINARY + 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"); + return true; + } + return false; + } + #endif + if (NULL != m_PointerFile) { + TK_CRITICAL("File Already open : \"" << GetCompleateName() << "\""); + return true; + } + m_PointerFile=fopen(GetCompleateName().c_str(),"rb"); + if(NULL == m_PointerFile) { + TK_ERROR("Can not find the file name=\"" << GetCompleateName() << "\""); + return false; + } + return true; +} + +bool etk::File::fOpenWrite(void) +{ + #ifdef DATA_INTERNAL_BINARY + if (etk::FILE_TYPE_DATA == m_type) { + m_readingOffset = 0; + return false; + } + #endif + if (NULL != m_PointerFile) { + TK_CRITICAL("File Already open : \"" << GetCompleateName() << "\""); + return true; + } + m_PointerFile=fopen(GetCompleateName().c_str(),"wb"); + if(NULL == m_PointerFile) { + TK_ERROR("Can not find the file name=\"" << GetCompleateName() << "\""); + return false; + } + return true; +} + +bool etk::File::fClose(void) +{ + #ifdef DATA_INTERNAL_BINARY + if (etk::FILE_TYPE_DATA == m_type) { + m_readingOffset = 0; + if (m_idInternal >= -1 && m_idInternal < internalDataFilesSize) { + return true; + } + return false; + } + #endif + if (NULL == m_PointerFile) { + TK_CRITICAL("File Already closed : \"" << GetCompleateName() << "\""); + return false; + } + fclose(m_PointerFile); + m_PointerFile = NULL; + return true; +} + +char * etk::File::fGets(char * elementLine, int32_t maxData) +{ + #ifdef DATA_INTERNAL_BINARY + char * element = elementLine; + 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) { + element[0] = '\0'; + return NULL; + } + while (internalDataFiles[m_idInternal].data[m_readingOffset] != '\0') { + if( internalDataFiles[m_idInternal].data[m_readingOffset] == '\n' + || internalDataFiles[m_idInternal].data[m_readingOffset] == '\r') + { + *element = internalDataFiles[m_idInternal].data[m_readingOffset]; + element++; + m_readingOffset++; + *element = '\0'; + return elementLine; + } + *element = internalDataFiles[m_idInternal].data[m_readingOffset]; + element++; + m_readingOffset++; + // TODO : Understand why this does not work + /*if (m_readingOffset>internalDataFilesSize) { + *element = '\0'; + return elementLine; + }*/ + } + } + return NULL; + } + #endif + return fgets(elementLine, maxData, m_PointerFile); +} + +int32_t etk::File::fRead(void * data, int32_t blockSize, int32_t nbBlock) +{ + #ifdef DATA_INTERNAL_BINARY + 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); + dataToRead = blockSize * nbBlock; + } + memcpy(data, &internalDataFiles[m_idInternal].data[m_readingOffset], dataToRead); + m_readingOffset +=dataToRead; + return nbBlock; + } + return 0; + } + #endif + return fread(data, blockSize, nbBlock, m_PointerFile); +} + +int32_t etk::File::fWrite(void * data, int32_t blockSize, int32_t nbBlock) +{ + #ifdef DATA_INTERNAL_BINARY + if (etk::FILE_TYPE_DATA == m_type) { + TK_CRITICAL("Can not write on data inside memory : \"" << GetCompleateName() << "\""); + return 0; + } + #endif + return fwrite(data, blockSize, nbBlock, m_PointerFile); +} + + +char * etk::File::GetDirectPointer(void) +{ + #ifdef DATA_INTERNAL_BINARY + if (etk::FILE_TYPE_DATA == m_type) { + if (m_idInternal >= -1 && m_idInternal < internalDataFilesSize) { + return (char*)internalDataFiles[m_idInternal].data; + } + } + #endif + return NULL; +} diff --git a/Sources/etk/File.h b/Sources/etk/File.h index 10caf9f0..b20e0d2a 100644 --- a/Sources/etk/File.h +++ b/Sources/etk/File.h @@ -33,13 +33,36 @@ namespace etk { + typedef enum { + // user might done abstraction ==> acces of the sdcard when possible ... + FILE_TYPE_DIRECT, + + // depend of the case + // - PC : /usr/shared/programName/ + // - Android : Internal at the executable file (pointer on static area) + // - Apple : Internal at the executable file + FILE_TYPE_DATA, + + // depend on case + // - PC : ~/.programName/ + // - Android : /data/data/programName/files/ + // - Apple : ???? + FILE_TYPE_USER_DATA, + + // depend on case + // - PC : ~/.programName/cache/ + // - Android : /data/data/programName/cache/ + // - Apple : ???? + FILE_TYPE_CACHE, + } FileType_te; + class File { public: - File(void) { m_lineNumberOpen=0; } - File(etk::String &filename, int32_t LineNumber = 0); - File(const char *filename, int32_t LineNumber = 0); - File(etk::String &filename, etk::String &folder, int32_t lineNumber = 0); + File(void) { m_lineNumberOpen=0; m_type = etk::FILE_TYPE_DIRECT; m_PointerFile = NULL;} + File(etk::String &filename, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t LineNumber = 0); + File(const char *filename, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t LineNumber = 0); + File(etk::String &filename, etk::String &folder, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t lineNumber = 0); ~File(void); etk::String GetFolder(void) const; etk::String GetShortFilename(void) const; @@ -50,23 +73,41 @@ namespace etk bool Exist(void); int32_t GetLineNumber(void); void SetLineNumber(int32_t newline); - void SetCompleateName(etk::String &newFilename); + void SetCompleateName(etk::String &newFilename, etk::FileType_te type); const etk::File& operator= (const etk::File &etkF ); bool operator== (const etk::File &etkF ) const; bool operator!= (const etk::File &etkF ) const; friend etk::CCout& operator <<( etk::CCout &os,const etk::File &obj); + FileType_te GetTypeAccess(void) { return m_type; }; + char * GetDirectPointer(void); + + // TODO : IO access of the file : + bool fOpenRead(void); + bool fOpenWrite(void); + bool fClose(void); + 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); private : - etk::String m_folder; - etk::String m_shortFilename; - int32_t m_lineNumberOpen; + etk::FileType_te m_type; + FILE * m_PointerFile; + #ifdef DATA_INTERNAL_BINARY + int32_t m_idInternal; + int32_t m_readingOffset; + #endif + etk::String m_folder; + etk::String m_shortFilename; + int32_t m_lineNumberOpen; }; etk::CCout& operator <<(etk::CCout &os, const etk::File &obj); - void SetBaseFolder(const char * folder); - + void SetBaseFolderData(const char * folder); + void SetBaseFolderDataUser(const char * folder); + void SetBaseFolderCache(const char * folder); + } #endif diff --git a/Sources/ewol/FontBitmap.cpp b/Sources/ewol/FontBitmap.cpp index 7acd7dfb..a9f98a18 100644 --- a/Sources/ewol/FontBitmap.cpp +++ b/Sources/ewol/FontBitmap.cpp @@ -67,16 +67,16 @@ namespace ewol tmpchar.ratio = 0; m_elements.PushBack(tmpchar); } - FILE* File=fopen(m_filename.GetCompleateName().c_str(),"r"); - if(NULL == File) { + if(false == m_filename.fOpenRead()) { EWOL_ERROR("Can not find the file name=\"" << m_filename << "\""); return; } // load all element of the file ... char elementLine[2048]; int32_t lineID=1; - while (NULL != fgets(elementLine, 2048, File) ) + while (NULL != m_filename.fGets(elementLine, 2048) ) { + EWOL_DEBUG(" Read file Line : " << elementLine); if ( '\n' != elementLine[0] // EOL && '\0' != elementLine[0] // EOF && '#' != elementLine[0] // Comment line @@ -113,11 +113,12 @@ namespace ewol lineID++; } // close the file at end of reading... - fclose(File); + m_filename.fClose(); // Load Bitmap : etk::String bitmapRealFile = m_filename.GetFolder() + "/" + m_bitmapName; EWOL_INFO("load text font image : \"" << bitmapRealFile << "\""); - m_textureId = ewol::LoadTexture(bitmapRealFile); + etk::File tmpFile(bitmapRealFile, m_filename.GetTypeAccess()); + m_textureId = ewol::LoadTexture(tmpFile); m_textureLoaded = true; m_loadedOK = true; }; @@ -270,7 +271,7 @@ int32_t ewol::LoadFont(etk::String fontName, int32_t size) { // check if folder file etk::String tmpFileName = s_currentFolderName + "/" + fontName + ".ebt"; - etk::File fileName(tmpFileName); + etk::File fileName(tmpFileName, etk::FILE_TYPE_DATA); if (false == fileName.Exist()) { EWOL_ERROR("Font does not exist: \"" << fileName.GetCompleateName() << "\""); return -1; diff --git a/Sources/ewol/Texture.cpp b/Sources/ewol/Texture.cpp index acb99688..82ede40e 100644 --- a/Sources/ewol/Texture.cpp +++ b/Sources/ewol/Texture.cpp @@ -88,10 +88,10 @@ class Bitmap FILE *File=NULL; // Get the fileSize ... - if (fileName.Size() < (int32_t)(sizeof(bitmapFileHeader_ts) + sizeof(bitmapInfoHeader_ts) ) ) { + /*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) { EWOL_ERROR("Can not find the file name=\"" << fileName << "\""); diff --git a/Sources/ewol/theme/Theme.cpp b/Sources/ewol/theme/Theme.cpp index 2ef7bad7..3e586137 100644 --- a/Sources/ewol/theme/Theme.cpp +++ b/Sources/ewol/theme/Theme.cpp @@ -58,7 +58,15 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme) } else { TiXmlDocument XmlDocument; // open the curent File - XmlDocument.LoadFile(newFile.GetCompleateName().c_str()); + #ifdef DATA_INTERNAL_BINARY + if (etk::FILE_TYPE_DATA == newFile.GetTypeAccess()) { + XmlDocument.Parse(newFile.GetDirectPointer()); + } else { + XmlDocument.LoadFile(newFile.GetCompleateName().c_str()); + } + #else + XmlDocument.LoadFile(newFile.GetCompleateName().c_str()); + #endif TiXmlElement* root = XmlDocument.FirstChildElement( "eol" ); if (NULL == root ) { EWOL_ERROR("(l ?) main node not find: \"eol\" in \"" << newFile << "\""); diff --git a/assets/Font/ebtfont/Monospace.bmp b/assets/Font/ebtfont/Monospace.bmp deleted file mode 100644 index abbde028..00000000 Binary files a/assets/Font/ebtfont/Monospace.bmp and /dev/null differ diff --git a/assets/Font/ebtfont/Monospace.ebt b/assets/Font/ebtfont/Monospace.ebt deleted file mode 100644 index 574d98cc..00000000 --- a/assets/Font/ebtfont/Monospace.ebt +++ /dev/null @@ -1,129 +0,0 @@ -name:Monospace -source:Monospace.bmp -# comment line ... -# size 54 largeur 33 space between letter 12 -# unknow UTF8 code of the letter and start coordonate and size ==> 0x54 (33,45) (33,54) -0x00 (99,453) (33,54) # Error : Unknow the UTF8 element ... -# hexa UTF8 code of the letter and start coordonate and size ==> 0x54 (33,45) (33,54) -# ABCDEFGHIJKLMN -0x20 (0,7) (33,54) # space ... -0x41 (33,7) (33,54) # A -0x42 (66,7) (33,54) # B -0x43 (99,7) (33,54) # C -0x44 (132,7) (33,54) # D -0x45 (165,7) (33,54) # E -0x46 (198,7) (33,54) # F -0x47 (231,7) (33,54) # G -0x48 (264,7) (33,54) # H -0x49 (297,7) (33,54) # I -0x4A (330,7) (33,54) # J -0x4B (363,7) (33,54) # K -0x4C (396,7) (33,54) # L -0x4D (429,7) (33,54) # M -0x4E (462,7) (33,54) # N -#OPQRSTUVWXYZabc -0x4F (0,71) (33,54) # O -0x50 (33,71) (33,54) # P -0x51 (66,71) (33,54) # Q -0x52 (99,71) (33,54) # R -0x53 (132,71) (33,54) # S -0x54 (165,71) (33,54) # T -0x55 (198,71) (33,54) # U -0x56 (231,71) (33,54) # V -0x57 (264,71) (33,54) # W -0x58 (297,71) (33,54) # X -0x59 (330,71) (33,54) # Y -0x5A (363,71) (33,54) # Z -0x61 (396,71) (33,54) # a -0x62 (429,71) (33,54) # b -0x63 (462,71) (33,54) # c -#defghijklmnopqr -0x64 (0,135) (33,54) # d -0x65 (33,135) (33,54) # e -0x66 (66,135) (33,54) # f -0x67 (99,135) (33,54) # g -0x68 (132,135) (33,54) # h -0x69 (165,135) (33,54) # i -0x6A (198,135) (33,54) # j -0x6B (231,135) (33,54) # k -0x6C (264,135) (33,54) # l -0x6D (297,135) (33,54) # m -0x6E (330,135) (33,54) # n -0x6F (363,135) (33,54) # o -0x70 (396,135) (33,54) # p -0x71 (429,135) (33,54) # q -0x72 (462,135) (33,54) # r -#stuvwxyz1234567 -0x73 (0,199) (33,54) # s -0x74 (33,199) (33,54) # t -0x75 (66,199) (33,54) # u -0x76 (99,199) (33,54) # v -0x77 (132,199) (33,54) # w -0x78 (165,199) (33,54) # x -0x79 (198,199) (33,54) # y -0x7A (231,199) (33,54) # z -0x31 (264,199) (33,54) # 1 -0x32 (297,199) (33,54) # 2 -0x33 (330,199) (33,54) # 3 -0x34 (363,199) (33,54) # 4 -0x35 (396,199) (33,54) # 5 -0x36 (429,199) (33,54) # 6 -0x37 (462,199) (33,54) # 7 -#890&é~"#'{([-|è -0x38 (0,263) (33,54) # 8 -0x39 (33,263) (33,54) # 9 -0x30 (66,263) (33,54) # 0 -0x26 (99,263) (33,54) # & -#0x (132,263) (33,54) # é -0x7E (165,263) (33,54) # ~ -0x22 (198,263) (33,54) # " -0x23 (231,263) (33,54) # # -0x27 (264,263) (33,54) # ' -0x7B (297,263) (33,54) # { -0x28 (330,263) (33,54) # ( -0x5B (363,263) (33,54) # [ -0x2D (396,263) (33,54) # - -0x7C (429,263) (33,54) # | -#0x (462,263) (33,54) # è -#`_\ç^à@)]=} -0x60 (0,335) (33,54) # ` -0x5F (33,335) (33,54) # _ -0x5C (66,335) (33,54) # \ -#0x (99,335) (33,54) # ç -0x5E (132,335) (33,54) # ^ -#0x (165,335) (33,54) # à -0x40 (198,335) (33,54) # @ -0x29 (231,335) (33,54) # ) -0x5D (264,335) (33,54) # ] -0x3D (297,335) (33,54) # = -0x7D (330,335) (33,54) # } -#0x (363,335) (33,54) # o chap -#0x (396,335) (33,54) # u chap -#0x (429,335) (33,54) # e chap -#0x (462,335) (33,54) # a chap -#$£*µ%!§:/ -#0x (0,391) (33,54) # i chap -#0x (33,391) (33,54) # o trema -#0x (66,391) (33,54) # u trema -#0x (99,391) (33,54) # e trema -#0x (132,391) (33,54) # a trema -0x24 (165,391) (33,54) # $ -#0x (198,391) (33,54) # £ -0x2A (231,391) (33,54) # * -#0x (264,391) (33,54) # µ -#0x (297,391) (33,54) # ù -0x25 (330,391) (33,54) # % -0x21 (363,391) (33,54) # ! -#0x (396,391) (33,54) # § -0x3A (429,391) (33,54) # : -0x2F (462,391) (33,54) # / -#;.,?<>²!+ -0x3B (0,453) (33,54) # ; -0x2E (33,453) (33,54) # . -0x2C (66,453) (33,54) # , -0x3F (99,453) (33,54) # ? -0x3C (132,453) (33,54) # < -0x3E (165,453) (33,54) # > -#0x (198,453) (33,54) # ² -#0x21 (231,453) (33,54) # ! ==> doublon ... -0x2B (264,453) (33,54) # + diff --git a/assets/ic_luncher_ewoltest.png b/assets/ic_luncher_ewoltest.png deleted file mode 100644 index 14b2a40f..00000000 Binary files a/assets/ic_luncher_ewoltest.png and /dev/null differ diff --git a/assets/theme/exemple.eol b/assets/theme/exemple.eol deleted file mode 100644 index 8cc0a533..00000000 --- a/assets/theme/exemple.eol +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Font/ebtfont/Monospace.bmp b/dataTest/Font/ebtfont/Monospace.bmp similarity index 100% rename from Font/ebtfont/Monospace.bmp rename to dataTest/Font/ebtfont/Monospace.bmp diff --git a/Font/ebtfont/Monospace.ebt b/dataTest/Font/ebtfont/Monospace.ebt similarity index 99% rename from Font/ebtfont/Monospace.ebt rename to dataTest/Font/ebtfont/Monospace.ebt index 574d98cc..249ba667 100644 --- a/Font/ebtfont/Monospace.ebt +++ b/dataTest/Font/ebtfont/Monospace.ebt @@ -1,6 +1,6 @@ name:Monospace source:Monospace.bmp -# comment line ... +#comment line ... # size 54 largeur 33 space between letter 12 # unknow UTF8 code of the letter and start coordonate and size ==> 0x54 (33,45) (33,54) 0x00 (99,453) (33,54) # Error : Unknow the UTF8 element ... diff --git a/Font/freefont/AUTHORS b/dataTest/Font/freefont/AUTHORS similarity index 100% rename from Font/freefont/AUTHORS rename to dataTest/Font/freefont/AUTHORS diff --git a/Font/freefont/COPYING b/dataTest/Font/freefont/COPYING similarity index 100% rename from Font/freefont/COPYING rename to dataTest/Font/freefont/COPYING diff --git a/Font/freefont/CREDITS b/dataTest/Font/freefont/CREDITS similarity index 100% rename from Font/freefont/CREDITS rename to dataTest/Font/freefont/CREDITS diff --git a/Font/freefont/ChangeLog b/dataTest/Font/freefont/ChangeLog similarity index 100% rename from Font/freefont/ChangeLog rename to dataTest/Font/freefont/ChangeLog diff --git a/Font/freefont/FreeMono.ttf b/dataTest/Font/freefont/FreeMono.ttf similarity index 100% rename from Font/freefont/FreeMono.ttf rename to dataTest/Font/freefont/FreeMono.ttf diff --git a/Font/freefont/FreeMonoBold.ttf b/dataTest/Font/freefont/FreeMonoBold.ttf similarity index 100% rename from Font/freefont/FreeMonoBold.ttf rename to dataTest/Font/freefont/FreeMonoBold.ttf diff --git a/Font/freefont/FreeMonoBoldOblique.ttf b/dataTest/Font/freefont/FreeMonoBoldOblique.ttf similarity index 100% rename from Font/freefont/FreeMonoBoldOblique.ttf rename to dataTest/Font/freefont/FreeMonoBoldOblique.ttf diff --git a/Font/freefont/FreeMonoOblique.ttf b/dataTest/Font/freefont/FreeMonoOblique.ttf similarity index 100% rename from Font/freefont/FreeMonoOblique.ttf rename to dataTest/Font/freefont/FreeMonoOblique.ttf diff --git a/Font/freefont/FreeSans.ttf b/dataTest/Font/freefont/FreeSans.ttf similarity index 100% rename from Font/freefont/FreeSans.ttf rename to dataTest/Font/freefont/FreeSans.ttf diff --git a/Font/freefont/FreeSansBold.ttf b/dataTest/Font/freefont/FreeSansBold.ttf similarity index 100% rename from Font/freefont/FreeSansBold.ttf rename to dataTest/Font/freefont/FreeSansBold.ttf diff --git a/Font/freefont/FreeSansBoldOblique.ttf b/dataTest/Font/freefont/FreeSansBoldOblique.ttf similarity index 100% rename from Font/freefont/FreeSansBoldOblique.ttf rename to dataTest/Font/freefont/FreeSansBoldOblique.ttf diff --git a/Font/freefont/FreeSansOblique.ttf b/dataTest/Font/freefont/FreeSansOblique.ttf similarity index 100% rename from Font/freefont/FreeSansOblique.ttf rename to dataTest/Font/freefont/FreeSansOblique.ttf diff --git a/Font/freefont/FreeSerif.ttf b/dataTest/Font/freefont/FreeSerif.ttf similarity index 100% rename from Font/freefont/FreeSerif.ttf rename to dataTest/Font/freefont/FreeSerif.ttf diff --git a/Font/freefont/FreeSerifBold.ttf b/dataTest/Font/freefont/FreeSerifBold.ttf similarity index 100% rename from Font/freefont/FreeSerifBold.ttf rename to dataTest/Font/freefont/FreeSerifBold.ttf diff --git a/Font/freefont/FreeSerifBoldItalic.ttf b/dataTest/Font/freefont/FreeSerifBoldItalic.ttf similarity index 100% rename from Font/freefont/FreeSerifBoldItalic.ttf rename to dataTest/Font/freefont/FreeSerifBoldItalic.ttf diff --git a/Font/freefont/FreeSerifItalic.ttf b/dataTest/Font/freefont/FreeSerifItalic.ttf similarity index 100% rename from Font/freefont/FreeSerifItalic.ttf rename to dataTest/Font/freefont/FreeSerifItalic.ttf diff --git a/Font/freefont/INSTALL b/dataTest/Font/freefont/INSTALL similarity index 100% rename from Font/freefont/INSTALL rename to dataTest/Font/freefont/INSTALL diff --git a/Font/freefont/README b/dataTest/Font/freefont/README similarity index 100% rename from Font/freefont/README rename to dataTest/Font/freefont/README diff --git a/Font/freefont/date_2010-09-19.txt b/dataTest/Font/freefont/date_2010-09-19.txt similarity index 100% rename from Font/freefont/date_2010-09-19.txt rename to dataTest/Font/freefont/date_2010-09-19.txt diff --git a/tools/fileToCpp.cpp b/tools/fileToCpp.cpp new file mode 100644 index 00000000..d1a65606 --- /dev/null +++ b/tools/fileToCpp.cpp @@ -0,0 +1,219 @@ +/** + ******************************************************************************* + * @file pngToCpp.cpp + * @brief convert a binary file into a C source vector + * @author Sandro Sigala + * @date 26/01/2011 + * @par Project + * --- + * + * @version $Id$ + * + * @par Copyright + * THE "BEER-WARE LICENSE" (Revision 3.1415): + * sandro AT sigala DOT it wrote this file. As long as you retain this notice you can do + * whatever you want with this stuff. If we meet some day, and you think this stuff is + * worth it, you can buy me a beer in return. Sandro Sigala + * + * @compilation g++ pngToCpp -o pngToCpp + * + ******************************************************************************* + */ + +#include +#include +#include +#include + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +bool zeroTerminated = false; + +int myfgetc(FILE *f) +{ + int c = fgetc(f); + if (c == EOF && zeroTerminated) + { + zeroTerminated = 0; + return 0; + } + return c; +} + +void generateHeader(FILE *file) +{ + fprintf(file, "/**\n"); + fprintf(file, " ******************************************************************************* \n"); + fprintf(file, " * \n"); + fprintf(file, " * @par Project\n"); + fprintf(file, " * Edn\n"); + fprintf(file, " * \n"); + fprintf(file, " * Automatic generated file for Edn Software\n"); + fprintf(file, " * Please do not save this file on File configuration server\n"); + fprintf(file, " * \n"); + fprintf(file, " * @par Copyright\n"); + fprintf(file, " * The copyright of the data depend on the source file but generated file is on GPL v3\n"); + fprintf(file, " * \n"); + fprintf(file, " * Copyright 2010 Edouard DUPIN, all right reserved\n"); + fprintf(file, " * \n"); + fprintf(file, " * This is free software; you can redistribute it and/or modify it under the\n"); + fprintf(file, " * terms of the GNU General Public License as published by the Free Software\n"); + fprintf(file, " * Foundation; either version 3 of the License, or (at your option) any later\n"); + fprintf(file, " * version.\n"); + fprintf(file, " * \n"); + fprintf(file, " * This software is distributed in the hope that it will be useful, but WITHOUT\n"); + fprintf(file, " * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n"); + fprintf(file, " * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n"); + fprintf(file, " * for more details.\n"); + fprintf(file, " * \n"); + fprintf(file, " ******************************************************************************* \n"); + fprintf(file, " */\n\n"); +} + +char endTable[256000] = ""; + +FILE *ofile=NULL; +FILE *ofileH=NULL; + +void process(const char *ifname) +{ + printf(" Import File : \"%s\"\n", ifname); + FILE *ifile=NULL; + ifile = fopen(ifname, "rb"); + if (ifile == NULL) + { + fprintf(stderr, "cannot open %s for reading\n", ifname); + exit(1); + } + char buf[PATH_MAX], *p; + const char *cp; + if ((cp = strrchr(ifname, '/')) != NULL) + { + ++cp; + } else { + if ((cp = strrchr(ifname, '\\')) != NULL) + ++cp; + else + cp = ifname; + } + strcpy(buf, cp); + for (p = buf; *p != '\0'; ++p) + { + if (!isalnum(*p)) + *p = '_'; + } + fprintf(ofile, "unsigned char %s[] = {", buf); + int n = 0; + unsigned char c = 0; + while(fread(&c, 1, 1, ifile) == 1) + { + if(n%100 == 0) { + fprintf(ofile, "\n\t\t"); + } + fprintf(ofile, "0x%02x,", c); + n++; + } + 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); + strcat (endTable, tmpVar); + + fclose(ifile); +} + +void usage(void) +{ + fprintf(stderr, "usage: pngToCpp .xxx \n"); + exit(1); +} + +int main(int argc, char **argv) +{ + //zeroTerminated = true; + if (argc < 3) { + usage(); + } + // dynamic output name : + char tmpOutput[PATH_MAX*2] = ""; + strcpy(tmpOutput, argv[1]); + int32_t sizeName = strlen(tmpOutput); + if (6>=sizeName) { + usage(); + } + if (tmpOutput[sizeName-1] == '.') { + tmpOutput[sizeName-1] = '\0'; + } else if (tmpOutput[sizeName-2] == '.') { + tmpOutput[sizeName-2] = '\0'; + } else if (tmpOutput[sizeName-3] == '.') { + tmpOutput[sizeName-3] = '\0'; + } else if (tmpOutput[sizeName-4] == '.') { + tmpOutput[sizeName-4] = '\0'; + } else if (tmpOutput[sizeName-5] == '.') { + tmpOutput[sizeName-5] = '\0'; + } else if (tmpOutput[sizeName-6] == '.') { + tmpOutput[sizeName-6] = '\0'; + } + //fprintf(stderr, "writing to %s\n", tmpOutput); + + char tmpOutputCPP[PATH_MAX*2] = ""; + char tmpOutputH[PATH_MAX*2] = ""; + // Generate the output filename + sprintf(tmpOutputCPP,"%s.cpp", tmpOutput); + sprintf(tmpOutputH,"%s.h", tmpOutput); + // open destination name : + ofile = fopen(tmpOutputCPP, "wb"); + if (ofile == NULL) + { + fprintf(stderr, "cannot open %s for writing\n", tmpOutputCPP); + exit(1); + } + generateHeader(ofile); + ofileH = fopen(tmpOutputH, "wb"); + if (ofileH == NULL) + { + fprintf(stderr, "cannot open %s for writing\n", tmpOutputH); + exit(1); + } + generateHeader(ofileH); + fprintf(ofileH, "#ifndef __INPUT_PNG_FILE_GENERATED_H__\n"); + fprintf(ofileH, "#define __INPUT_PNG_FILE_GENERATED_H__\n\n"); + fprintf(ofileH, "extern \"C\" {\n"); + fprintf(ofileH, " typedef struct {\n"); + fprintf(ofileH, " char filename[1024];\n"); + fprintf(ofileH, " long int fileLenght;\n"); + fprintf(ofileH, " unsigned char * data;\n"); + fprintf(ofileH, " } internalData_ts;\n\n\n"); + + + // Generate the output + int32_t i; + for(i=2; i