Mercurial > mercurial > hgweb_golang.cgi
view src/kaigo/horori/searcher/src/utils.cpp @ 48:ca00c4a85b98
small changes.
author | pyon@macmini |
---|---|
date | Wed, 22 Apr 2020 19:00:50 +0900 |
parents | 169936fed61b |
children | 638e1ad05cae |
line wrap: on
line source
// Filename : utils.cpp // Last Change: 2020-04-22 09:21:01. // #include <wx/wx.h> #include <wx/dir.h> #include <wx/wfstream.h> #include <wx/zstream.h> #include <wx/tarstrm.h> #include "utils.h" wxRect Geo2Rect(wxString geo) { long w, h, x, y; wxString sw = geo.BeforeFirst('x'); wxString sh = geo.AfterFirst('x').BeforeFirst('+'); wxString sx = geo.AfterFirst('+').BeforeFirst('+'); wxString sy = geo.AfterLast('+'); sw.ToLong(&w, 10); sh.ToLong(&h, 10); sx.ToLong(&x, 10); sy.ToLong(&y, 10); return wxRect((int)x, (int)y, (int)w, (int)h); } wxRect ZeroRect() { wxRect rect(wxPoint(0, 0), wxPoint(0, 0)); return rect; } bool TarDir(wxString dir, wxString tarfile) { if (!wxDirExists(dir)) { wxMessageBox(wxT("bad directoy")); return false; } wxDir d(dir); if (!d.IsOpened()) return false; wxFFileOutputStream out(tarfile); wxTarOutputStream tar(out); wxString filename; bool cont = d.GetFirst(&filename, wxEmptyString, wxDIR_FILES); while (cont) { wxFFileInputStream in(dir + wxFILE_SEP_PATH + filename); tar.PutNextEntry(filename); tar.Write(in); cont = d.GetNext(&filename); } tar.Close(); return true; } bool Gzip(wxString infile, wxString gzfile) { wxFileInputStream istream(infile); wxFileOutputStream ostream(gzfile); wxZlibOutputStream zstream(ostream, -1, wxZLIB_GZIP); zstream.Write(istream); zstream.Close(); return true; }