6 #elif defined(GLib_CYGWIN)
7 TStr TZipIn::SevenZipPath =
"/usr/bin";
8 #elif defined(GLib_MACOSX)
9 TStr TZipIn::SevenZipPath =
"/usr/local/bin";
11 TStr TZipIn::SevenZipPath =
"/usr/bin";
21 PROCESS_INFORMATION piProcInfo;
22 STARTUPINFO siStartInfo;
23 ZeroMemory( &piProcInfo,
sizeof(PROCESS_INFORMATION));
24 ZeroMemory( &siStartInfo,
sizeof(STARTUPINFO));
25 siStartInfo.cb =
sizeof(STARTUPINFO);
27 siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
29 const BOOL FuncRetn = CreateProcess(NULL,
30 (LPSTR) CmdLine.
CStr(),
40 CloseHandle(piProcInfo.hProcess);
41 CloseHandle(piProcInfo.hThread);
45 ZipStdoutRd = popen((TZipIn::SevenZipPath+
"/"+CmdLine).CStr(),
"r");
62 BfL = (int) BytesRead;
69 FLen(0), CurFPos(0), Bf(NULL), BfC(0), BfL(0) {
75 printf(
"*** Error: file %s, compression format %s not supported\n", FNm.
CStr(), FNm.
GetFExt().
CStr());
80 if (FLen == 0) {
return; }
83 SECURITY_ATTRIBUTES saAttr;
84 saAttr.nLength =
sizeof(SECURITY_ATTRIBUTES);
85 saAttr.bInheritHandle = TRUE;
86 saAttr.lpSecurityDescriptor = NULL;
88 const int PipeBufferSz = 32*1024;
91 SetHandleInformation(
ZipStdoutRd, HANDLE_FLAG_INHERIT, 0);
101 FLen(0), CurFPos(0), Bf(NULL), BfC(0), BfL(0) {
107 SECURITY_ATTRIBUTES saAttr;
108 saAttr.nLength =
sizeof(SECURITY_ATTRIBUTES);
109 saAttr.bInheritHandle = TRUE;
110 saAttr.lpSecurityDescriptor = NULL;
114 SetHandleInformation(
ZipStdoutRd, HANDLE_FLAG_INHERIT, 0);
142 if (
Bf != NULL) {
delete[]
Bf; }
148 for (
TSize LBfC=0; LBfC<LBfL; LBfC++){
150 LBfS+=((
char*)LBf)[LBfC]=
Bf[
BfC++];}
152 for (
TSize LBfC=0; LBfC<LBfL; LBfC++){
153 LBfS+=(((
char*)LBf)[LBfC]=
Bf[
BfC++]);}
167 if (
BfC >=
BfL) { BfP = 0; }
172 if (Status == 1) {
return true; }
175 }
while (Status == 0);
177 return !LnChA.
Empty();
188 if (
Eof()) {
return -1; }
193 if (Ch==
'\n') { BfN =
BfC-1;
return 1; }
194 if (Ch==
'\r' &&
Bf[
BfC+1]==
'\n') {
195 BfC++; BfN =
BfC-2;
return 1; }
209 const char* ZipCmd =
"7z.exe e -y -bd -so";
211 const char* ZipCmd =
"7za e -y -bd -so";
236 SECURITY_ATTRIBUTES saAttr;
237 saAttr.nLength =
sizeof(SECURITY_ATTRIBUTES);
238 saAttr.bInheritHandle = TRUE;
239 saAttr.lpSecurityDescriptor = NULL;
241 const int PipeBufferSz = 32*1024;
242 EAssertR(CreatePipe(&ZipStdoutRd, &ZipStdoutWr, &saAttr, PipeBufferSz),
"Stdout pipe creation failed");
244 SetHandleInformation(ZipStdoutRd, HANDLE_FLAG_INHERIT, 0);
247 PROCESS_INFORMATION piProcInfo;
248 STARTUPINFO siStartInfo;
249 ZeroMemory( &piProcInfo,
sizeof(PROCESS_INFORMATION));
250 ZeroMemory( &siStartInfo,
sizeof(STARTUPINFO));
251 siStartInfo.cb =
sizeof(STARTUPINFO);
253 siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
255 const BOOL FuncRetn = CreateProcess(NULL, (LPSTR) CmdLine.
CStr(),
256 NULL, NULL, TRUE, 0, NULL, NULL, &siStartInfo, &piProcInfo);
258 CloseHandle(piProcInfo.hProcess);
259 CloseHandle(piProcInfo.hThread); }
262 FILE* ZipStdoutRd = popen(CmdLine.
CStr(),
"r");
263 if (ZipStdoutRd == NULL) {
264 ZipStdoutRd = popen((TZipIn::SevenZipPath+
"/"+CmdLine).CStr(),
"r");
269 const int BfSz = 32*1024;
270 char*
Bf =
new char [BfSz];
275 EAssert(ReadFile(ZipStdoutRd, Bf,
MxBfL, &BytesRead, NULL) != 0);
277 size_t BytesRead = fread(Bf, 1,
MxBfL, ZipStdoutRd);
279 EAssert(pclose(ZipStdoutRd) != -1);
282 BfC = 0; Bf[
BfL] = 0;
284 TStr Str(Bf);
delete []
Bf;
286 int n = StrV.
Len()-1;
287 while (n > 0 && ! StrV[n].IsPrefix(
"-----")) { n--; }
293 return StrV[n-7].GetInt64();
315 PROCESS_INFORMATION piProcInfo;
316 STARTUPINFO siStartInfo;
317 ZeroMemory( &piProcInfo,
sizeof(PROCESS_INFORMATION));
318 ZeroMemory( &siStartInfo,
sizeof(STARTUPINFO));
319 siStartInfo.cb =
sizeof(STARTUPINFO);
321 siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
323 const BOOL FuncRetn = CreateProcess(NULL,
324 (LPSTR) CmdLine.
CStr(),
334 CloseHandle(piProcInfo.hProcess);
335 CloseHandle(piProcInfo.hThread);
339 ZipStdinWr = popen((TZipIn::SevenZipPath+
"/"+CmdLine).CStr(),
"r");
349 SECURITY_ATTRIBUTES saAttr;
350 saAttr.nLength =
sizeof(SECURITY_ATTRIBUTES);
351 saAttr.bInheritHandle = TRUE;
352 saAttr.lpSecurityDescriptor = NULL;
356 SetHandleInformation(
ZipStdinWr, HANDLE_FLAG_INHERIT, 0);
376 if (
Bf!=NULL) {
delete[]
Bf; }
387 for (
TSize LBfC=0; LBfC<LBfL; LBfC++){
388 LBfS+=
PutCh(((
char*)LBf)[LBfC]);}
390 for (
TSize LBfC=0; LBfC<LBfL; LBfC++){
391 LBfS+=(
Bf[
BfL++]=((
char*)LBf)[LBfC]);}
413 const char* ZipCmd =
"7z.exe a -y -bd -si";
415 const char* ZipCmd =
"7za a -y -bd -si";
static TStrStrH FExtToCmdH
static TStr GetCmd(const TStr &ZipFNm)
Return a command-line string that is executed in order to decompress a file to standard output...
static TStr GetCmd(const TStr &ZipFNm)
Return a command-line string that is executed in order to decompress a file to standard output...
static void FillFExtToCmdH()
int PutCh(const char &Ch)
static bool Exists(const TStr &FNm)
TSizeTy Len() const
Returns the number of elements in the vector.
bool GetNextLnBf(TChA &LnChA)
const TDat & GetDat(const TKey &Key) const
static PSIn New(const TStr &FNm)
unsigned long long uint64
void SaveToErrLog(const char *MsgCStr)
static TStrStrH FExtToCmdH
static bool IsZipExt(const TStr &FNmExt)
Check whether the file extension FNmExt is that of a compressed file (.gz, .7z, .rar, .zip, .cab, .arj. bzip2).
static void FillFExtToCmdH()
int PutBf(const void *LBf, const TSize &LBfL)
static PSOut New(const TStr &FNm)
void AddBf(char *NewBf, const int &BfS)
static bool IsZipExt(const TStr &FNmExt)
Check whether the file extension FNmExt is that of a compressed file (.gz, .7z, .rar, .zip, .cab, .arj. bzip2).
static TStr Fmt(const char *FmtStr,...)
#define EAssertR(Cond, MsgStr)
void CreateZipProcess(const TStr &Cmd, const TStr &ZipFNm)
virtual TStr GetSNm() const
void WrNotify(const char *CaptionCStr, const char *NotifyCStr)
void SplitOnWs(TStrV &StrV) const
bool IsKey(const TKey &Key) const
int GetBf(const void *LBf, const TSize &LBfL)
void CreateZipProcess(const TStr &Cmd, const TStr &ZipFNm)
TDat & AddDat(const TKey &Key)