Changeset 227 for cpp/common/nonstd_stdio.cpp
- Timestamp:
- 04/20/14 01:48:23 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note: See TracChangeset
for help on using the changeset viewer.