NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) { nsCOMPtr<nsIInputStream> inStream; nsresult rv = MakeInputStream(getter_AddRefs(inStream), PR_TRUE); if (NS_FAILED(rv)) return rv; // Init our streampump rv = mPump->Init(inStream, PRInt64(-1), PRInt64(-1), 0, 0, PR_FALSE); if (NS_FAILED(rv)) return rv; rv = mPump->AsyncRead(this, ctxt); if (NS_SUCCEEDED(rv)) { // Store our real listener mListener = aListener; // Add ourself to the load group, if available if (mLoadGroup) mLoadGroup->AddRequest(this, nsnull); } return rv; }
bool ArcApp::Extract() { wxInputStreamPtr in(MakeInputStream()); if (!in.get()) return false; wxArchiveInputStreamPtr arc(m_factory->NewStream(*in)); wxArchiveEntryPtr entry; while (entry.reset(arc->GetNextEntry()), entry.get() != NULL) { if (!m_args.empty() && !entry->GetName().Matches(m_args[0])) continue; *m_info << "extracting " << entry->GetName().mb_str() << std::endl; wxFileName fn(entry->GetName()); if (entry->IsDir()) { fn.Mkdir(0777, wxPATH_MKDIR_FULL); } else { wxFileName::Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL); wxFFileOutputStream out(entry->GetName()); if (!out || !out.Write(*arc) || !arc->Eof()) return false; } #ifdef __WXMSW__ if (!entry->IsDir()) { #endif wxDateTime dt = entry->GetDateTime(); fn.SetTimes(NULL, &dt, NULL); #ifdef __WXMSW__ } #endif } return arc->Eof(); }
NS_IMETHODIMP nsIconChannel::Open(nsIInputStream **_retval) { return MakeInputStream(_retval, PR_FALSE); }
bool ArcApp::Add() { // turn m_args into a list of files, i.e. expand wildcards, recurse // directories and remove duplicates NameMap files; MakeFileList(files); wxInputStreamPtr in(MakeInputStream()); if (!in.get()) return false; wxOutputStreamPtr out(MakeOutputStream()); if (!out.get()) return false; wxArchiveInputStreamPtr arc(m_factory->NewStream(*in)); wxArchiveOutputStreamPtr outarc(m_factory->NewStream(*out)); wxArchiveEntryPtr entry(arc->GetNextEntry()); outarc->CopyArchiveMetaData(*arc); for (;;) { bool keep; NameMap::iterator it; if (!entry.get()) { if (files.empty()) break; it = files.begin(); keep = false; } else { it = files.find(entry->GetInternalName()); keep = true; } if (it != files.end()) { wxString name = it->second; files.erase(it); if (wxDirExists(name)) { *m_info << "adding " << name.mb_str() << std::endl; wxDateTime dt(wxFileModificationTime(name)); if (!outarc->PutNextDirEntry(name, dt)) return false; keep = false; } else { wxFFileInputStream file(name); if (file.Ok()) { *m_info << "adding " << name.mb_str() << std::endl; wxDateTime dt(wxFileModificationTime(name)); if (!outarc->PutNextEntry(name, dt, file.GetSize()) || !outarc->Write(file) || !file.Eof()) return false; keep = false; } } } if (keep) if (!outarc->CopyEntry(entry.release(), *arc)) return false; if (entry.get() || keep) entry.reset(arc->GetNextEntry()); } in.reset(); return arc->Eof() && outarc->Close() && out->Close(); }