ADM_audioAccessFile::ADM_audioAccessFile(const char *fileName,int offset) { _offset=offset; fileLength=ADM_fileSize(fileName)-offset; _fd=ADM_fopen(fileName,"rb"); ADM_assert(_fd); }
bool FileSystem::getFileSize( string path_, File::Size& size_ ) { /* size_ = 0; struct stat buf; if( stat( path_.c_str(), &buf )) return true; size_ = buf.st_size; return false; */ size_=ADM_fileSize(path_.c_str()); return false; }
/** * \fn loadShader * @param src * @return */ bool shaderLoader::loadShader(const char *src) { if(!ADM_fileExist(src)) { ADM_warning("Shader file does not exist (%s)\n",src); return false; } int sourceSize=ADM_fileSize(src); if(sourceSize<5) { ADM_warning("Shader file is too short(%s)\n",src); return false; } uint8_t *buffer=(uint8_t *)admAlloca(sourceSize+1); FILE *f=fopen(params.shaderFile.c_str(),"rt"); if(!f) { ADM_warning("Cannot open file %s\n",src); return false; } fread(buffer,sourceSize,1,f); buffer[sourceSize]=0; fclose(f); f=NULL; if(glProgramY) { delete glProgramY; glProgramY=NULL; } glProgramY = createShaderFromSource(QOpenGLShader::Fragment,(char *)buffer); if(!glProgramY) { ADM_error("Shader compiling failed\n"); return false; } ADM_info("Shader %s successfully loaded an compiled\n",src); return true; }
/* Open one file, probe to see if there is several file with contiguous name and handle them as one big file if that's the case If multi is set to probe, return value will be APPEND if there is several files, dont_append if one if multi is set to dont_append, file won't be auto appended even if they exist */ uint8_t fileParser::open( const char *filename,FP_TYPE *multi ) { uint32_t decimals = 0; // number of decimals char *left = NULL, *right = NULL; // parts of filename (after splitting) uint8_t count = 0; // number of follow-ups uint32_t base=0; bool splitFile=false; // int i = 0; // index (general use) if(*multi!=FP_DONT_APPEND) { aprintf("Checking if there are several files...\n"); splitFile=ADM_splitSequencedFile(filename, &left, &right,&decimals,&base); if(splitFile) { aprintf("left:<%s>, right=<%s>,base=%" PRIu32",digit=%" PRIu32"\n",left,right,base,decimals); }else { aprintf("No.\n"); } } // ____________________ // Single loading // ____________________ if( false ==splitFile ) { fdIo newFd; aprintf( "\nSimple loading: \n" ); _curFd = 0; FILE *f=NULL; // open file if(! (f = ADM_fopen(filename, "rb")) ) { return 0; } newFd.file=f; // calculate file-size fseeko( f, 0, SEEK_END ); newFd.fileSize = ftello( f ); fseeko( f, 0, SEEK_SET ); newFd.fileSizeCumul=0; _size=newFd.fileSize; listOfFd.append(newFd); aprintf( " file: %s, size: %" PRIu64"\n", filename, newFd.fileSize ); aprintf( " found 1 files \n" ); aprintf( "Done \n" ); return 1; } // ____________________ // Multi loading // ____________________ uint32_t tabSize; std::string leftPart(left); std::string rightPart(right); delete [] left; delete [] right; left=NULL; right=NULL; aprintf( "\nAuto adding: \n" ); uint32_t current=base; _curFd = 0; uint64_t total=0; // build match string char match[16]; match[0]='%'; match[1]='0'; sprintf(match+2,"%d",decimals); // snprintf instead ... strcat(match,"d"); match[15]=0; aprintf("Using %s as match string\n",match); char number[16]; while(1) { sprintf(number,match,current); std::string middle(number); std::string outName=leftPart+middle+rightPart; aprintf("Checking %s\n",outName.c_str()); // open file FILE *f= ADM_fopen(outName.c_str(), "rb"); if(!f) { // we need at least one file! if( !count ) { return 0; } else { printf( " file: %s not found. \n", outName.c_str() ); break; } } // calculate file-size fdIo myFd; myFd.file=f; myFd.fileSize=ADM_fileSize(outName.c_str()); myFd.fileSizeCumul = total; total+= myFd.fileSize; aprintf( " file %d: %s, size: %" PRIu64"\n", (count + 1), outName.c_str(), myFd.fileSize ); listOfFd.append(myFd); count++; current++; } _size=total; // clean up if(*multi==FP_PROBE) { if(count>1) *multi=FP_APPEND; // else *multi=FP_DONT_APPEND; } aprintf( " found %d files \n", count ); aprintf( "Done \n" ); return 1; } // fileParser::open()