bool Image::loadFromFile(String fileName) { complete = false; std::vector<uint8_t>* bytes; static String b64("data:image/png;base64,"); if (fileName.size() > b64.size() && String(fileName.begin(), fileName.begin() + b64.size()) == b64) { // Read image from Base64 encoded URL bytes = fromBase64(fileName.c_str() + b64.size()); complete = loadFromBuffer(bytes->data(), bytes->size()); delete bytes; __BGRA = false; } else { CocoAssetFile* file = CocoAssetFile::open(fileName); if (file) { complete = loadFromBuffer(file->getData(), file->bytesLength()); delete file; } } if (complete) src = fileName; return complete; }
void C64::loadFromSnapshot(Snapshot *snapshot) { if (snapshot == NULL) return; uint8_t *ptr = snapshot->getData(); loadFromBuffer(&ptr); }
bool ofXml::load(const string & path){ ofFile file(path, ofFile::ReadOnly); if(!file.exists()) { ofLogError("ofXml") << "couldn't load, \"" << file.getFileName() << "\" not found"; return false; } ofBuffer xmlBuffer(file); return loadFromBuffer(xmlBuffer); }
bool CBigramHistory::loadFromFile(const char *fname) { m_history_path = fname; bool suc = false; int fd = open(fname, O_CREAT, 0600); if (fd == -1) { suc = loadFromBuffer(NULL, 0); return suc; } struct stat info; fstat(fd, &info); void* buf = malloc(info.st_size); if (buf) { read(fd, buf, info.st_size); suc = loadFromBuffer(buf, info.st_size); free(buf); } close(fd); return suc; }
void CSPIniReadWrite::readFile(void) { File file(m_strPath); if (file.existsAsFile()) { ScopedPointer<FileInputStream> pInputStream(file.createInputStream()); if (pInputStream) { size_t nSize = static_cast<size_t>(file.getSize()); MemoryBlock memoryBlock(nSize + 1, true); if (pInputStream->read(memoryBlock.getData(), nSize) == nSize) { loadFromBuffer((byte*)memoryBlock.getData(), nSize); } } } }
void HrtfData::loadFromFile(std::string path, unsigned int forSr) { //first, load the file if we can. FILE *fp = fopen(path.c_str(), "rb"); if(fp == nullptr) ERROR(Lav_ERROR_FILE, std::string("Could not find HRTF file ")+path); size_t size = 0; fseek(fp, 0, SEEK_END); size = ftell(fp); fseek(fp, 0, SEEK_SET); //Okay, load everything. char* data = new char[size]; //do the read. size_t read; read = fread(data, 1, size, fp); loadFromBuffer(read, data, forSr); delete[] data; }
bool Shader::loadFromFile(std::string directory, std::string filename) { if(!filename.length()) return false; Debug& dbg = Debug::instance(); dbg << "Loading shader "; int indent = dbg.getIndentLevel(); dbg.setIndentLevel(0); dbg << filename << "...\n"; dbg.setIndentLevel(indent); dbg.flush(); char* buffer = readFileSource(std::string(directory + filename).c_str()); if(!buffer) return false; bool success = loadFromBuffer(buffer); free(buffer); return success; }
void HrtfData::loadFromDefault(unsigned int forSr) { loadFromBuffer(default_hrtf_size, default_hrtf, forSr); }