static bool InTimePlusSeconds (const wxDateTime & time, ubyte8 next, int DeltaSeconds) { if (next >= time.GetValue ().GetValue ()) { wxDateTime schedule (TimeTToWxDateTime (next)); wxTimeSpan span = schedule - time; if (span.GetSeconds () <= DeltaSeconds) return true; } return false; }
wxGzipOutputStream::wxGzipOutputStream( wxOutputStream& stream, const wxString& originalName /*=wxEmptyString*/, #if wxUSE_DATETIME const wxDateTime& originalTime /*=wxDateTime::Now()*/, #endif int level /*=-1*/, wxMBConv& conv /*=wxConvFile*/) : wxFilterOutputStream(stream) { m_comp = NULL; m_crc = crc32(0, Z_NULL, 0); wxFileName filename(originalName); wxUint32 timestamp = 0; #if wxUSE_DATETIME if (originalTime.IsValid()) timestamp = (originalTime.GetValue() / 1000L).GetLo(); #endif // RFC-1952 specifies ISO-8859-1 for the name. Also it should be just the // name part, no directory, folded to lowercase if case insensitive wxString name = filename.GetFullName(); const wxWX2MBbuf mbName = conv.cWX2MB(name); wxDataOutputStream ds(*m_parent_o_stream); // write signature, method, flags, timestamp, extra flags and OS-code ds.Write16(GZ_MAGIC); ds.Write8(Z_DEFLATED); ds.Write8(mbName && *mbName ? GZ_ORIG_NAME : 0); ds.Write32(timestamp); ds.Write8(level == 1 ? GZ_FASTEST : level == 9 ? GZ_SLOWEST : 0); ds.Write8(255); if (mbName && *mbName) m_parent_o_stream->Write(mbName, strlen(mbName) + 1); m_lasterror = wxSTREAM_WRITE_ERROR; if (!*m_parent_o_stream) { wxLogDebug(wxT("Error writing Gzip header")); return; } m_comp = new wxZlibOutputStream(*m_parent_o_stream, level, wxZLIB_NO_HEADER); if (m_comp) m_lasterror = m_comp->GetLastError(); }
void wxTarOutputStream::SetHeaderDate(const wxString& key, const wxDateTime& datetime) { wxLongLong ll = datetime.IsValid() ? datetime.GetValue() : wxLongLong(0); wxLongLong secs = ll / 1000L; if (key != wxT("mtime") || !m_hdr->SetOctal(TAR_MTIME, wxTarNumber(secs.GetValue())) || secs <= 0 || secs >= 0x7fffffff) { wxString str; if (ll >= LONG_MIN && ll <= LONG_MAX) { str.Printf(wxT("%g"), ll.ToLong() / 1000.0); } else { str = ll.ToString(); str.insert(str.end() - 3, '.'); } SetExtendedHeader(key, str); } }
void* CygwinDlg::CygwinInstallThread::Entry() { wxString cygPath = eDocumentPath::GetCygwinDir(); if (cygPath.empty()) { // Make sure it get eventual proxy settings from IE wxFileName::Mkdir(wxT("C:\\cygwin\\etc\\setup\\"), 0777, wxPATH_MKDIR_FULL); wxFile file(wxT("C:\\cygwin\\etc\\setup\\last-connection"), wxFile::write); file.Write(wxT("IE")); cygPath = wxT("C:\\cygwin"); } const wxString supportPath = m_appPath + wxT("Support\\bin"); const wxString packages = wxT("curl,wget,tidy,perl,python,ruby,file,libiconv"); const wxString cmd = wxString::Format(wxT("%s\\cygwin-setup-p.exe"), supportPath); wxString options; if (m_mode == cxCYGWIN_AUTO) { options = wxString::Format(wxT("--quiet-mode --site http://mirrors.dotsrc.org/cygwin/ --package %s --root \"%s\""), packages, cygPath); } else { options = wxString::Format(wxT("--package %s"), packages); } // Run Setup // We have to use ShellExecute to enable Vista UAC elevation SHELLEXECUTEINFO sei = { sizeof(sei) }; sei.fMask = SEE_MASK_NOASYNC|SEE_MASK_NOCLOSEPROCESS; sei.nShow = SW_SHOWNORMAL; sei.lpFile = cmd.c_str(); sei.lpParameters = options.c_str(); if (!::ShellExecuteEx(&sei)) return NULL; // Wait for setup to complete if (sei.hProcess != 0) { ::WaitForSingleObject(sei.hProcess, INFINITE); ::CloseHandle(sei.hProcess); } // Path may have been changed during install cygPath = eDocumentPath::GetCygwinDir(); if (cygPath.empty()) return NULL; // Setup environment cxEnv env; env.SetToCurrent(); env.SetEnv(wxT("TM_SUPPORT_PATH"), eDocumentPath::WinPathToCygwin(m_appPath + wxT("Support"))); // needed by post-install // Run postinstall cxExecute exec(env); exec.SetUpdateWindow(false); exec.SetShowWindow(false); const wxString supportScript = supportPath + wxT("\\cygwin-post-install.sh"); const wxString postCmd = wxString::Format(wxT("\"%s\\bin\\bash\" --login \"%s\""), cygPath, supportScript); const int postexit = exec.Execute(postCmd); if (postexit != 0) { wxLogDebug(wxT("post-install failed %d"), postexit); // return NULL; // don't return. May fail on Vista } // Mark this update as done const wxFileName supportFile(supportScript); const wxDateTime updateTime = supportFile.GetModificationTime(); eGetSettings().SetSettingLong(wxT("cyg_date"), updateTime.GetValue()); return NULL; }