SeekableReadStream *CdfArchive::createReadStreamForMember(const String &name) const { SeekableReadStream *stream = NULL; const FileEntry *file_entry = GetFileEntry(name); if(file_entry != NULL) { byte *data_ptr = (byte *)malloc(file_entry->size); // compressed file if(file_entry->compressed) FileDecode((uint8 *)data_ptr, file_entry->size, file_entry->offset); // uncompressed file else { //TODO: sequential reading for this case? m_File.seek(file_entry->offset); m_File.read(data_ptr, file_entry->size); } stream = new MemoryReadStream(data_ptr, file_entry->size, DisposeAfterUse::YES); } return stream; }
static int near ripsendbatch(int fDisplay) { int rc=TRUE; logit("@ripsendbatch(%s,fnames=%d)", fDisplay ?"true":"false", FileEntries()); if (FileEntries()) { long bytes; int fn; FENTRY fent; bytes=0L; for (fn=0; GetFileEntry(fn, &fent); ++fn) bytes += fent.ulSize; /* Tell the remote system we're sending some files... * 4=composite dynamic file: just send, remote sorts out where they go * 5=active dynamic file: send, remote sorts out & displays as well */ Printf("\r!|0\x1b""070%c0000<>\n", (fDisplay) ? '5' : '4'); /* Now, send 'em, forcing ZModem */ if ((rc=File_Send_Files_Sub(PROTOCOL_ZMODEM, NULL, NULL, bytes, FALSE))!=FALSE) { /* Add the file names sent to the "sent" list to avoid both * having to to ask the user's terminal again or having to * resend at all unless we're forced to do so via '!' */ for (fn=0; GetFileEntry(fn, &fent); fn++) addripfile(fent.szName); } Free_Filenames_Buffer(0); } return rc; }
bool CdfArchive::hasFile(const String &name) const { return GetFileEntry(name) != NULL; }
void MaxWriteCtl(struct _proto *pro, word ul) { FILE *ctl; char fname[PATHLEN]; word n; long bd=steady_baud_l ? steady_baud_l : baud; FENTRY fent; /* Delete any preexisting log file */ Parse_Outside_Cmd(pro->log, fname); unlink(fname); /* Handle the "%" translation characters */ Parse_Outside_Cmd(pro->ctl, fname); if ((ctl=fopen(fname, fopen_write))==NULL) { cant_open(fname); return; } /* If we need to handle an Opus-style control file, do so now */ if (pro->flag & P_OPUS) { if (local) fprintf(ctl, xctl_keyboard); else fprintf(ctl, xctl_port_baud, port+1, bd); if (!local) fprintf(ctl, xctl_modem, port+1, bd, prm.handshake_mask /* 3 */, prm.carrier_mask, baud); fprintf(ctl, xctl_time, timeleft()); if (log_name && *log_name) fprintf(ctl, xctl_log, log_name); fprintf(ctl, xctl_msgs, MAS(mah, path)); fprintf(ctl, xctl_uploads, FAS(fah, uppath)); fprintf(ctl, xctl_downloads, FAS(fah, downpath)); fprintf(ctl, xctl_help, original_path); if (fah.heap) { if (*FAS(fah, filesbbs)) fprintf(ctl, xctl_filesbbs, FAS(fah, filesbbs)); } } /* Now write out the names of the files to send */ for (n=0; GetFileEntry(n, &fent); n++) { fprintf(ctl, ul ? pro->ulstr : pro->dlstr, fent.szName); fputc('\n', ctl); } /* Close the control file */ fclose(ctl); }
word MaxReadLog(struct _proto *pro, word doing_ul) { FILE *log; #define LOGLEN 255 char fname[PATHLEN]; char line[LOGLEN]; word gotfile=FALSE; char tempname[PATHLEN]; FENTRY fent; /* Handle the "%" translation characters */ Parse_Outside_Cmd(pro->log, fname); if ((log=fopen(fname, fopen_read))==NULL) { cant_open(fname); return FALSE; } while (fgets(line, LOGLEN, log)) { char *ulstr, *dlstr, *got, *desc; word ul; word fn; /* Find the positions of the upload and download strings */ dlstr=strstr(line, pro->dlkey); ulstr=strstr(line, pro->ulkey); if (ulstr==NULL && dlstr==NULL) continue; if (pro->flag & P_BI) { /* Use whichever token comes FIRST in the log line, since we might * * see either. */ ul=(ulstr && (dlstr==NULL || ulstr < dlstr)); got=(ul ? ulstr : dlstr); } else { /* Otherwise, just get the one that was requested */ ul=doing_ul; got=(ul ? ulstr : dlstr); if (!got) continue; } /* Now copy the filename, based on the word# we're supposed to get. */ getword(got, fname, ctl_delim, pro->fnamword+1); /* Skip it if we didn't get anything */ if (*fname=='\0') continue; /* Now figure out if we requested this file or not... */ for (fn=0; GetFileEntry(fn, &fent); fn++) if (eqstri(No_Path(fent.szName), No_Path(fname))) break; if (fn==FileEntries()) memset(&fent, 0, sizeof fent); /* Grab the description, if any */ desc=pro->descword ? firstchar(got, ctl_delim, pro->descword) : NULL; if (desc) fent.szDesc=desc; /* If we're doing an upload, strip the path specification */ if (ul) { strcpy(tempname, No_Path(fname)); fent.szName=tempname; /* Now figure out the fully-qualified path/name of the file so * that we can get the correct size. */ sprintf(fname, ss, FAS(fah, uppath), fent.szName); } else { fent.szName=fname; } /* Now get the size of this file */ fent.ulSize = fsize(fent.szName); if (ul) { logit(log_ul, *pro->desc, FAS(fah, uppath), fent.szName); fent.fFlags |= FFLAG_GOT; } else { fent.fFlags |= FFLAG_SENT; } UpdFileEntry(fn, &fent); gotfile=TRUE; } fclose(log); /* If the transfer was successful, delete both the .CTL and .LOG files */ if (gotfile) { Parse_Outside_Cmd(pro->log, fname); unlink(fname); Parse_Outside_Cmd(pro->ctl, fname); unlink(fname); } return gotfile; }
std::unique_ptr<N2pkIStream> N2pkFile::GetFile(const std::string& path) const { auto& fileEntry = GetFileEntry(path); auto buf = new substreambuf(m_stream->rdbuf(), fileEntry.GetOffset(), fileEntry.GetSize()); return std::make_unique<N2pkIStream>(buf); }
std::unique_ptr<N2pkIStream> N2pkFile::GetFile(unsigned int index) const { auto& fileEntry = GetFileEntry(index); auto buf = new substreambuf(m_stream->rdbuf(), fileEntry.GetOffset(), fileEntry.GetSize()); return std::make_unique<N2pkIStream>(buf); }
extern void UpdateWidgetData(WidgetData *data) { GtkWidget *widget; widget = GetWidgetByLongName(data->name); g_return_if_fail(widget != NULL); switch (data->type) { // gtk+panda case WIDGET_TYPE_NUMBER_ENTRY: GetNumberEntry(widget, (_NumberEntry*)data->attrs); break; case WIDGET_TYPE_PANDA_CLIST: GetPandaCList(widget, (_CList*)data->attrs); break; case WIDGET_TYPE_PANDA_ENTRY: case WIDGET_TYPE_ENTRY: GetEntry(widget, (_Entry*)data->attrs); break; case WIDGET_TYPE_PANDA_TEXT: GetText(widget, (_Text*)data->attrs); break; case WIDGET_TYPE_PANDA_TIMER: GetPandaTimer(widget, (_Timer*)data->attrs); break; case WIDGET_TYPE_PANDA_TABLE: GetPandaTable(widget, (_Table*)data->attrs); break; case WIDGET_TYPE_TEXT: GetText(widget, (_Text*)data->attrs); break; case WIDGET_TYPE_TOGGLE_BUTTON: case WIDGET_TYPE_CHECK_BUTTON: case WIDGET_TYPE_RADIO_BUTTON: GetButton(widget, (_Button*)data->attrs); break; case WIDGET_TYPE_CALENDAR: GetCalendar(widget, (_Calendar*)data->attrs); break; case WIDGET_TYPE_NOTEBOOK: GetNotebook(widget, (_Notebook*)data->attrs); break; case WIDGET_TYPE_PROGRESS_BAR: GetProgressBar(widget, (_ProgressBar*)data->attrs); break; case WIDGET_TYPE_SCROLLED_WINDOW: GetScrolledWindow(widget, (_ScrolledWindow*)data->attrs); break; case WIDGET_TYPE_FILE_CHOOSER_BUTTON: GetFileChooserButton(widget, (_FileChooserButton*)data->attrs); break; case WIDGET_TYPE_COLOR_BUTTON: GetColorButton(widget, (_ColorButton*)data->attrs); break; // gtk+ case WIDGET_TYPE_FILE_ENTRY: GetFileEntry(widget, (_FileEntry*)data->attrs); break; default: MessageLogPrintf("invalid widget [%s]", data->name); break; } }