Changeset 227 for cpp/common
- Timestamp:
- 04/20/14 01:48:23 (11 years ago)
- Location:
- cpp/common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/nonstd.h
r220 r227 81 81 #ifdef __ANDROID__ 82 82 #define GET_APP_HOME getAppHome() 83 #define GET_APP_RESOURCES " ./" //w APK trzymamy w katalogu w "assets", bo w "res" nie ma podkatalogow ani odwolywania sie po nazwach83 #define GET_APP_RESOURCES "/resrc/" //inside APK, resources are kept in the "assets" subdirectory (in the "res" subdirectory there is no support for subdirectories nor accessing files by name). The prefix /resrc/ is just an indication that lets mfile easily discriminate between HOME (r/w) and RESOURCES (r) locations 84 84 #endif 85 85 -
cpp/common/nonstd_math.cpp
r226 r227 24 24 25 25 26 #if defined LINUX || defined TIZEN || defined __ANDROID__ 26 #if defined LINUX || defined TIZEN || defined __ANDROID__ || defined IPHONE 27 27 28 28 #include <fenv.h> … … 44 44 #endif 45 45 46 47 #ifdef IPHONE48 49 #include <fenv.h>50 51 void fpExceptInit()52 {}53 54 void fpExceptEnable()55 {56 feclearexcept(FE_DIVBYZERO | FE_OVERFLOW);57 //feenableexcept(FE_DIVBYZERO | FE_OVERFLOW);58 }59 60 void fpExceptDisable()61 {62 //fedisableexcept(FE_DIVBYZERO | FE_OVERFLOW);63 }64 #endif65 46 66 47 -
cpp/common/nonstd_stdio.cpp
r215 r227 139 139 140 140 #ifdef __ANDROID__ 141 //#include "framsg.h"141 #include "framsg.h" 142 142 #include "nonstd.h" 143 #include "nonstd_stl.h" 143 144 MFILE *mfopen(const char *path, const char *mode) 144 145 { 145 NvFile *rfile=NULL; //umie tylko czytac 146 string respath=GET_APP_RESOURCES; //the macro can be char* or std::string, we don't know (nonstd.h, INITIAL_DIR_IS_RES, cwd.cpp) so we convert it to std::string 147 //printFM("Opening '%s', mode='%s'",path,mode); 148 //printFM("GET_APP_RESOURCES='%s'",respath.c_str()); 149 NvFile *rfile=NULL; //can only read 146 150 FILE *rwfile=NULL; 147 if (strstr(path,GET_APP_RESOURCES)==path) //otwieramy resource! wiec uzywamy czytania z assets 148 { 149 if (path[0]=='.' && path[1]=='/') path+=2; //nie rozpoznaje sciezek "./costam", a w sailorze zrobiles tak ze nie moze byc pusty path bo to jest znacznik ze jest niezainicjowany, dlatego uzywasz "./" i musimy je tu obcinac 150 rfile=NvFOpen(path); //"mode" not supported! umie tylko czytac 151 if (strstr(path,respath.c_str())==path) //opening resource! so we use a dedicated way to read from assets 152 { 153 path+=respath.length(); //strip the prefix, we need a relative path in assets 154 if (strstr(mode,"w")) 155 printFM("Warning: attempt to open a read-only resource '%s' in writable mode '%s'",path,mode); 156 rfile=NvFOpen(path); //"mode" not supported! can only read 157 //printFM("Opened RES file as %p",rfile); 151 158 if (rfile==NULL) return NULL; 152 } else // "normalny" dostep (doHOME)159 } else //a "normal" access (HOME) 153 160 { 154 161 rwfile=fopen(path,mode); 162 //printFM("Opened HOME file as %p",rwfile); 155 163 if (rwfile==NULL) return NULL; 156 164 } … … 174 182 { 175 183 if (f->rfile) 176 return size==0?0:NvFRead(ptr, size, count, f->rfile)/size; //blad nvidii w interpretacji zwracanej wartosci - zwraca liczbe bajtow zamiast liczbe porcji184 return NvFRead(ptr, size, count, f->rfile); //nvidia introduced my corrections in SDK v10.14, so a fix is no longer needed here 177 185 else 178 186 return fread(ptr, size, count, f->rwfile); … … 182 190 { 183 191 if (f->rfile) 184 return 0; //write not supported funkcjami nvidii192 return 0; //write not supported in assets using nvidia functions 185 193 else 186 194 return fwrite(ptr, size, count, f->rwfile); … … 197 205 { 198 206 if (f->rfile) 199 return NvFGets(str, num, f->rfile); 207 { 208 char *ret=NvFGets(str, num, f->rfile); 209 //fixing nvidia inconsistency... their function never returns NULL (fix submitted) 210 if (ret!=NULL && *ret==0 && num>0) //nothing has been read, must have been eof 211 return NULL; 212 return ret; 213 } 200 214 else 201 215 return fgets(str,num,f->rwfile); … … 213 227 { 214 228 if (f->rfile) 215 return NvFSeek(f->rfile, position, type) ==-1; // off_t AAsset_seek(AAsset* asset, off_t offset, int whence): Returns the new position on success, or (off_t) -1 on error.229 return NvFSeek(f->rfile, position, type); //nvidia introduced my corrections in SDK v10.14, so a fix is no longer needed here 216 230 else 217 231 return fseek(f->rwfile, position, type); -
cpp/common/nonstd_stdio.h
r201 r227 45 45 #include <nv_file/nv_file.h> 46 46 struct rwFILE //jedno z dwoch pol jest zainicjowane w zaleznosci od tego gdzie jest plik 47 { 48 NvFile *rfile; // umie tylko czytac47 { //nvidia uses a similar trick in nv_file.h (STD_FILE and APK_FILE), maybe doing a similar thing here is redundant? but their trick uses some trial-and-error code (see NvFOpen()) 48 NvFile *rfile; //can only read 49 49 FILE *rwfile; 50 50 rwFILE() {rfile=rwfile=NULL;}
Note: See TracChangeset
for help on using the changeset viewer.