OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
gunzip4c4group.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007, G√ľnther Brammer
3  * Copyright (c) 2010-2016, The OpenClonk Team and contributors
4  *
5  * Distributed under the terms of the ISC license; see accompanying file
6  * "COPYING" for details.
7  *
8  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
9  * See accompanying file "TRADEMARK" for details.
10  *
11  * To redistribute this file separately, substitute the full license texts
12  * for the above references.
13  */
14 
15 #include "C4Include.h"
16 #include "c4group/CStdFile.h"
17 #include <stdio.h>
18 
19 bool EraseItemSafe(const char *szFilename)
20 {
21  return false;
22 }
23 
24 int main(int argc, char *argv[])
25 {
26  if (argc < 2)
27  {
28  fprintf(stderr, "%s infile [outfile]", argv[0]);
29  return 1;
30  }
31  CStdFile MyFile;
32  MyFile.Open(argv[1], true);
33  char Data [4096];
34  size_t iSize;
35  if (argc < 3)
36  {
37  do
38  {
39  MyFile.Read(Data,sizeof(Data),&iSize);
40  fwrite(Data, 1, iSize, stdout);
41  }
42  while(iSize);
43  }
44  else
45  {
46  CStdFile OutFile;
47  OutFile.Create(argv[2], false);
48  do
49  {
50  MyFile.Read(Data,sizeof(Data),&iSize);
51  OutFile.Write(Data, iSize);
52  }
53  while(iSize);
54  OutFile.Close();
55  }
56  MyFile.Close();
57 }
bool Close(StdBuf **ppMemory=nullptr)
Definition: CStdFile.cpp:155
bool Create(const char *szFileName, bool fCompressed=false, bool fExecutable=false, bool fMemory=false)
Definition: CStdFile.cpp:53
bool Write(const void *pBuffer, int iSize)
Definition: CStdFile.cpp:244
int main(int argc, char *argv[])
bool Read(void *pBuffer, size_t iSize) override
Definition: CStdFile.h:61
bool EraseItemSafe(const char *szFilename)
bool Open(const char *szFileName, bool fCompressed=false)
Definition: CStdFile.cpp:99
int iSize
Definition: TstC4NetIO.cpp:35