int cBoblight::close() { if(m_boblight != 0) { tell(1, "Destroying boblight"); boblight_destroy(m_boblight); // calls delete *void m_boblight = 0; } // set pointer to 0 return success; }
Offset length( Descriptor file ) { if( file == InvalidDescriptor ) return InvalidOffset; Offset curPosition = tell( file ); Offset length = seekToEnd( file ); seek( file, curPosition, seekFromStart ); return length; }
void JsonIn::uneat_whitespace() { while (tell() > 0) { stream->seekg(-1, std::istream::cur); if (!is_whitespace(peek())) { break; } } }
/** \fn begin \brief Mark the beginning of a subchunk */ bool riffWritter::begin(const char *subchunk) { _begin=tell(); write32((_fcc)); write32((uint32_t) 0); // size write32((fourCC::get((uint8_t *) subchunk))); return 1; }
hime_lsize_t PosixStream::seek(hime_lpos_t offset, IO::SeekOrigin org) { static int whence[] = { SEEK_SET, SEEK_CUR, SEEK_END }; if (fseeko((FILE*)m_file, offset, whence[org]) != 0) throw_errno(m_path.c_str()); return tell(); }
int ow_getopt(int nargc, char ** nargv, char *ostr) { static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ if (!*place) { /* update scanning pointer */ if (optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return (EOF); if (*place == '-') { /* found "--" */ ++optind; return (EOF); } } /* option letter okay? */ if ((optopt = (int) *place++) == (int) ':' || !(oli = index(ostr, optopt))) { if (!*place) ++optind; tell(": illegal option -- "); } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) optarg = place; /* no white space */ else if (nargc <= ++optind) { /* no arg */ place = EMSG; tell(": option requires an argument -- "); } else optarg = nargv[optind]; /* white space */ place = EMSG; ++optind; } return (optopt); /* dump back option letter */ }
void IWriter::close_chunk() { VERIFY(!chunk_pos.empty()); int pos = tell(); seek(chunk_pos.top()); w_u32(pos - chunk_pos.top() - 4); seek(pos); chunk_pos.pop(); }
types::str file::read(int size) { if (not is_open) throw ValueError("I/O operation on closed file"); if (mode.find_first_of("r+") == -1) throw IOError("File not open for reading"); if (size == 0 or (feof(**data) && mode.find_first_of("ra") == -1)) return types::str(); int curr_pos = tell(); seek(0, SEEK_END); size = size < 0 ? tell() - curr_pos : size; seek(curr_pos); char *content = new char[size + 1]; // This part needs a new implementation of types::str(char*) to avoid // unnecessary copy. types::str res(content, fread(content, sizeof(char), size, **data)); delete[] content; return res; }
Int64 FileInputStream::getSize() { #ifdef ANDROID return m_file->getSize(); #else if (m_file) { Int64 position = tell(); std::fseek(m_file, 0, SEEK_END); Int64 size = tell(); seek(position); return size; } else { return -1; } #endif }
int LmcCom::responseP(char*& result) { // LogDuration ld("response", 0); int status = fail; char* buf = 0; result = 0; // wait op to 30 seconds to receive answer .. if (look(30000) == success && (buf = readln())) { char* p = buf + strlen(escId) +1; if ((p = strstr(p, lastCommand)) && strlen(p) >= strlen(lastCommand)) { p += strlen(lastCommand); while (*p && *p == ' ') // skip leading blanks p++; if (strcmp(p, "?") != 0) result = strdup(p); if (loglevel >= eloDebug) tell(eloDebug2, "<- (response %d bytes) [%s]", strlen(buf), unescape(p)); status = success; } else { tell(eloAlways, "Got unexpected answer for '%s' [%s]", lastCommand, buf); status = fail; } } free(buf); return status; }
int LmcCom::execute(const char* command, const char* par) { LmcLock; tell(eloDetail, "Exectuting '%s' with '%s'", command, par); request(command, par); write("\n"); return response(); }
int LmcCom::execute(const char* command, Parameters* pars) { LmcLock; tell(eloDetail, "Exectuting '%s' with %d parameters", command, pars ? pars->size() : 0); request(command, pars); write("\n"); return response(); }
u64 File::size() { #define E do { if (error()) return 0; } while (false) const auto prev_pos = tell(); E; seek(0, Seek::End); E; const auto ret = tell(); E; seek(prev_pos, Seek::Begin); return ret; #undef E }
void main(void) { int handle; char buffer[512]; int bytes_read; if ((handle = open("\\CONFIG.SYS", O_RDONLY)) == -1) printf("Error opening \\CONFIG.SYS\n"); else { printf("Current file position %ld\n", tell(handle)); while (bytes_read = read(handle, buffer, sizeof(buffer))) write(1, buffer, bytes_read); printf("Current file position %ld\n", tell(handle)); close(handle); } }
int getopt(int nargc, char **nargv, char *ostr) { static char *place = EMSG; /* option letter processing */ static char *lastostr = (char *) 0; register char *oli; /* option letter list index */ /* LANCE PATCH: dynamic reinitialization */ if (ostr != lastostr) { lastostr = ostr; place = EMSG; } if(!*place) { /* update scanning pointer */ if((optind >= nargc) || (*(place = nargv[optind]) != '-') || ! *++place) { place = EMSG; return(EOF); } if (*place == '-') { /* found "--" */ ++optind; return(EOF); } } /* option letter okay? */ if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr,optopt))) { if(!*place) ++optind; tell(": illegal option -- "); } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) optarg = place; /* no white space */ else if (nargc <= ++optind) { /* no arg */ place = EMSG; tell(": option requires an argument -- "); } else optarg = nargv[optind]; /* white space */ place = EMSG; ++optind; } return(optopt); /* dump back option letter */ }
ssize_t BufferedFile::read(void *ptr, size_t count) { ssize_t ret = 0; ssize_t offset = tell(); ret = fread(ptr, count, 1, m_fp) * count; if( IDBLogger::isEnabled() ) IDBLogger::logRW("read", m_fname, this, offset, count, ret); return ret; }
bool NoSeekFile::seek(std::streampos pos) { #ifdef GNASH_NOSEEK_FD_WARN_SEEKSBACK if (pos < tell()) { std::cerr << boost::format("Warning: seek backward requested " "(%ld from %ld)") % pos % tell() << std::endl; } #endif fill_cache(pos); if (std::fseek(_cache, pos, SEEK_SET) == -1) { std::cerr << "Warning: fseek failed" << std::endl; return false; } return true; }
WResFileOffset res_tell( WResFileID fid ) { if( fid == hInstance.fid ) { return( tell( WRES_FID2PH( fid ) ) ); } DbgAssert( WRES_FID2PH( fid ) == Root->outfile->handle ); fid = fid; return( PosLoad() ); }
void zip_archive_stream_blob::read(unsigned char* buffer, size_t length) const { if (!length) return; // First, make sure we have enough blob to satisfy the requested stream length. const size_t length_available = m_size - tell(); if (length_available < length) throw zip_error("There is not enough stream left to fill requested length."); memcpy(buffer, m_cur, length); }
ssize_t BufferedFile::write(const void *ptr, size_t count) { ssize_t ret = 0; off64_t offset = tell(); ret = fwrite(ptr, count, 1, m_fp) * count; if( IDBLogger::isEnabled() ) IDBLogger::logRW("write", m_fname, this, offset, count, ret); return ret; }
unsigned long file_size(void) { llong fpos, fsize; if (load_fd < 0) return 0; /* save current position */ fpos=tell(load_fd); /* go to end of file and get position */ seek_io(load_fd, -1); fsize=tell(load_fd); /* go back to old position */ seek_io(load_fd, 0); seek_io(load_fd, fpos); return fsize; }
unsigned long QFileSize( f_handle file ) /**************************************/ { unsigned long curpos; unsigned long size; curpos = tell( file ); size = lseek( file, 0L, SEEK_END ); lseek( file, curpos, SEEK_SET ); return( size ); }
int LmcCom::checkNotify(uint64_t timeout) { // LogDuration ld("checkNotify", 0); char buf[1000+TB]; int status = wrnNoEventPending; metaDataChanged = no; if (!notify) { tell(eloAlways, "Cant check for notifications until startNotify is called"); return fail; } while (notify->look(timeout) == success) { if (notify->read(buf, 1000, yes) == success) { buf[strlen(buf)-1] = 0; // cut LF unescape(buf); tell(eloDebug, "<- [%s]", buf); if (strstr(buf, "playlist ")) status = success; else if (strstr(buf, "pause ") || strstr(buf, "server")) status = success; else if (strstr(buf, "newmetadata")) { metaDataChanged = yes; status = success; } } } if (status == success) update(); return status; }
sf::Int64 FileStream::seek(sf::Int64 position) { if (m_file) { std::fseek(m_file, static_cast<std::size_t>(position), SEEK_SET); return tell(); } else { return -1; } }
sf_count_t SoundFile::Memory::read(void* ptr, sf_count_t count, void* user) { Memory* memory = static_cast<Memory*>(user); sf_count_t position = tell(user); if (position + count >= memory->size) count = memory->size - position; std::memcpy(ptr, memory->current, static_cast<std::size_t>(count)); memory->current += count; return count; }
inline BOOL ByteStreamInFile::seek(const I64 position) { if (tell() != position) { #ifdef _WIN32 return !(_fseeki64(file, position, SEEK_SET)); #else return !(fseeko(file, (off_t)position, SEEK_SET)); #endif } return TRUE; }
int tell(TreeNode *a, int v,int ind){ if(a==NULL) return -1; if(a->val == v){ arr1[ind] = a->val; x=ind;//cout<<x<<" "<<ind<<"haha"; return ind; } arr1[ind] = a->val; if(a->left){ int ans = tell(a->left, v, ind+1); if(ans !=-1) return ans; } if(a->right){ int ans = tell(a->right, v, ind+1); if(ans !=-1) return ans; } return -1; }
int GFFFile::finalWriteLists(void) { if(seek(offlistidx)) return errcode; for(uint32 i=0;i<lists.size();i++) { listoffs.push_back(tell()-offlistidx); if(binWrite((uint32) lists[i].size())) return errcode; for(uint32 j=0;j<lists[i].size();j++) if(binWrite(lists[i][j])) return errcode; } return errcode = 0; }
//--------------------------------------------------- // base stream IReader* IReader::open_chunk(u32 ID) { BOOL bCompressed; u32 dwSize = find_chunk(ID, &bCompressed); if (dwSize != 0) { if (bCompressed) { BYTE* dest; unsigned dest_sz; _decompressLZ(&dest, &dest_sz, pointer(), dwSize); return xr_new<CTempReader>(dest, dest_sz, tell() + dwSize); } else { return xr_new<IReader>(pointer(), dwSize, tell() + dwSize); } } else return 0; };
int64 FileOutputStream::seek(int64 position) { if (mFile) { std::fseek(mFile, static_cast<std::size_t>(position), SEEK_SET); return tell(); } else { return -1; } }