KiCad PCB EDA Suite
project_archiver.cpp File Reference
#include <wx/dir.h>
#include <wx/filedlg.h>
#include <wx/fs_zip.h>
#include <wx/uri.h>
#include <wx/wfstream.h>
#include <wx/zipstrm.h>
#include <macros.h>
#include <project/project_archiver.h>
#include <reporter.h>
#include <wildcards_and_files_ext.h>

Go to the source code of this file.

Macros

#define ZipFileExtension   wxT( "zip" )
 

Functions

static bool CopyStreamData (wxInputStream &inputStream, wxOutputStream &outputStream, wxFileOffset size)
 

Macro Definition Documentation

◆ ZipFileExtension

#define ZipFileExtension   wxT( "zip" )

Definition at line 33 of file project_archiver.cpp.

Function Documentation

◆ CopyStreamData()

static bool CopyStreamData ( wxInputStream &  inputStream,
wxOutputStream &  outputStream,
wxFileOffset  size 
)
static

Definition at line 42 of file project_archiver.cpp.

44 {
45  wxChar buf[128 * 1024];
46  int readSize = 128 * 1024;
47  wxFileOffset copiedData = 0;
48 
49  for (;;)
50  {
51  if (size != -1 && copiedData + readSize > size)
52  readSize = size - copiedData;
53 
54  inputStream.Read( buf, readSize );
55 
56  size_t actuallyRead = inputStream.LastRead();
57  outputStream.Write( buf, actuallyRead );
58 
59  if( outputStream.LastWrite() != actuallyRead )
60  {
61  wxLogError( "Failed to output data" );
62  //return false;
63  }
64 
65  if (size == -1)
66  {
67  if (inputStream.Eof())
68  break;
69  }
70  else
71  {
72  copiedData += actuallyRead;
73  if( copiedData >= size )
74  break;
75  }
76  }
77 
78  return true;
79 }

Referenced by PROJECT_ARCHIVER::Unarchive().