OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
CStdFile Class Reference

#include <CStdFile.h>

Inheritance diagram for CStdFile:
[legend]
Collaboration diagram for CStdFile:
[legend]

Public Member Functions

 CStdFile ()
 
 ~CStdFile () override
 
bool Create (const char *szFileName, bool fCompressed=false, bool fExecutable=false, bool fMemory=false)
 
bool Open (const char *szFileName, bool fCompressed=false)
 
bool Append (const char *szFilename, bool text=false)
 
bool Close (StdBuf **ppMemory=nullptr)
 
bool Default ()
 
bool Read (void *pBuffer, size_t iSize) override
 
bool Read (void *pBuffer, size_t iSize, size_t *ipFSize)
 
bool Write (const void *pBuffer, int iSize)
 
bool WriteString (const char *szStr)
 
bool Rewind ()
 
bool Advance (int iOffset) override
 
int Seek (long int offset, int whence)
 
long int Tell ()
 
bool IsOpen () const
 
bool Flush ()
 
size_t AccessedEntrySize () const override
 

Public Attributes

bool Status
 
char Name [_MAX_PATH+1]
 

Protected Member Functions

void ClearBuffer ()
 
int LoadBuffer ()
 
bool SaveBuffer ()
 

Protected Attributes

FILE * hFile
 
gzFile hgzFile
 
StdBufpMemory
 
int MemoryPtr
 
BYTE Buffer [CStdFileBufSize]
 
int BufferLoad
 
int BufferPtr
 
bool ModeWrite
 
StdThreadCheck thread_check
 

Detailed Description

Definition at line 38 of file CStdFile.h.

Constructor & Destructor Documentation

CStdFile::CStdFile ( )

Definition at line 32 of file CStdFile.cpp.

References ClearBuffer(), hFile, hgzFile, ModeWrite, Name, pMemory, StdThreadCheck::Set(), Status, and thread_check.

33 {
34  thread_check.Set();
35  Status=false;
36  hFile=nullptr;
37  hgzFile=nullptr;
38  pMemory=nullptr;
39  ClearBuffer();
40  ModeWrite=false;
41  Name[0]=0;
42 }
FILE * hFile
Definition: CStdFile.h:46
bool Status
Definition: CStdFile.h:43
bool ModeWrite
Definition: CStdFile.h:52
StdThreadCheck thread_check
Definition: CStdFile.h:53
void Set()
Definition: StdSync.h:294
char Name[_MAX_PATH+1]
Definition: CStdFile.h:44
gzFile hgzFile
Definition: CStdFile.h:47
void ClearBuffer()
Definition: CStdFile.cpp:234
StdBuf * pMemory
Definition: CStdFile.h:48

Here is the call graph for this function:

CStdFile::~CStdFile ( )
override

Definition at line 44 of file CStdFile.cpp.

References Close().

45 {
46  Close();
47 }
bool Close(StdBuf **ppMemory=nullptr)
Definition: CStdFile.cpp:151

Here is the call graph for this function:

Member Function Documentation

size_t CStdFile::AccessedEntrySize ( ) const
overridevirtual

Implements CStdStream.

Definition at line 347 of file CStdFile.cpp.

References FileSize(), hFile, and hgzFile.

348 {
349  if (hFile)
350  return FileSize(fileno(hFile));
351  assert(!hgzFile);
352  return 0;
353 }
FILE * hFile
Definition: CStdFile.h:46
size_t FileSize(const char *fname)
gzFile hgzFile
Definition: CStdFile.h:47

Here is the call graph for this function:

bool CStdFile::Advance ( int  iOffset)
overridevirtual

Implements CStdStream.

Definition at line 285 of file CStdFile.cpp.

References BufferLoad, BufferPtr, StdThreadCheck::Check(), hFile, LoadBuffer(), ModeWrite, and thread_check.

286 {
288  if (ModeWrite) return false;
289  while (iOffset > 0)
290  {
291  // Valid data in the buffer: Transfer as much as possible
292  if (BufferLoad > BufferPtr)
293  {
294  int transfer = std::min(BufferLoad-BufferPtr,iOffset);
295  BufferPtr += transfer;
296  iOffset -= transfer;
297  }
298  // Buffer empty: Load or skip
299  else
300  {
301  if (hFile) return !fseek(hFile, iOffset, SEEK_CUR); // uncompressed: Just skip
302  if (LoadBuffer()<=0) return false; // compressed: Read...
303  }
304  }
305  return true;
306 }
int BufferPtr
Definition: CStdFile.h:51
FILE * hFile
Definition: CStdFile.h:46
bool ModeWrite
Definition: CStdFile.h:52
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53
int BufferLoad
Definition: CStdFile.h:51
int LoadBuffer()
Definition: CStdFile.cpp:213

Here is the call graph for this function:

bool CStdFile::Append ( const char *  szFilename,
bool  text = false 
)

Definition at line 132 of file CStdFile.cpp.

References _MAX_PATH, ClearBuffer(), GetWideChar(), hFile, ModeWrite, Name, SCopy(), StdThreadCheck::Set(), Status, and thread_check.

Referenced by C4TableGraph::DumpToFile(), and C4MessageInput::ProcessCommand().

133 {
134  SCopy(szFilename,Name,_MAX_PATH);
135  thread_check.Set();
136  // Set modes
137  ModeWrite=true;
138  // Open standard file
139 #ifdef _WIN32
140  if (!(hFile = _wfopen(GetWideChar(Name), text ? L"at" : L"ab"))) return false;
141 #else
142  if (!(hFile=fopen(Name,text ? "at" : "ab"))) return false;
143 #endif
144  // Reset buffer
145  ClearBuffer();
146  // Set status
147  Status=true;
148  return true;
149 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
FILE * hFile
Definition: CStdFile.h:46
bool Status
Definition: CStdFile.h:43
#define _MAX_PATH
bool ModeWrite
Definition: CStdFile.h:52
StdThreadCheck thread_check
Definition: CStdFile.h:53
void Set()
Definition: StdSync.h:294
char Name[_MAX_PATH+1]
Definition: CStdFile.h:44
void ClearBuffer()
Definition: CStdFile.cpp:234

Here is the call graph for this function:

Here is the caller graph for this function:

void CStdFile::ClearBuffer ( )
protected

Definition at line 234 of file CStdFile.cpp.

References BufferLoad, BufferPtr, StdThreadCheck::Check(), and thread_check.

Referenced by Append(), Create(), CStdFile(), Open(), and Rewind().

235 {
238 }
int BufferPtr
Definition: CStdFile.h:51
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53
int BufferLoad
Definition: CStdFile.h:51

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::Close ( StdBuf **  ppMemory = nullptr)

Definition at line 151 of file CStdFile.cpp.

References BufferLoad, c4_gzclose(), StdThreadCheck::Check(), hFile, hgzFile, MemoryPtr, ModeWrite, Name, pMemory, SaveBuffer(), Status, and thread_check.

Referenced by C4Playback::Clear(), C4ConfigGeneral::CreateSaveFolder(), C4UpdatePackage::Execute(), C4Group::ExtractEntry(), GetFileCRC(), GetFileSHA1(), main(), C4UpdatePackage::MakeUpdate(), C4Group::Open(), C4MessageInput::ProcessCommand(), C4PXSSystem::Save(), CSurface8::Save(), C4Group::Save(), C4Record::Stop(), and ~CStdFile().

152 {
154  bool rval=true;
155  Status=false;
156  Name[0]=0;
157  // Save buffer if in write mode
158  if (ModeWrite && BufferLoad) if (!SaveBuffer()) rval=false;
159  // Close file(s)
160  if (hgzFile) if (c4_gzclose(hgzFile)!=Z_OK) rval=false;
161  if (hFile) if (fclose(hFile)!=0) rval=false;
162  if (pMemory)
163  {
164  if (ppMemory)
165  { *ppMemory = pMemory; pMemory = nullptr; }
166  else
167  delete pMemory;
168  }
169  MemoryPtr=0;
170  hgzFile=nullptr; hFile=nullptr;
171  return !!rval;
172 }
FILE * hFile
Definition: CStdFile.h:46
bool Status
Definition: CStdFile.h:43
bool ModeWrite
Definition: CStdFile.h:52
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53
int ZEXPORT c4_gzclose(gzFile file)
Definition: gzio.c:964
int BufferLoad
Definition: CStdFile.h:51
bool SaveBuffer()
Definition: CStdFile.cpp:222
int MemoryPtr
Definition: CStdFile.h:49
char Name[_MAX_PATH+1]
Definition: CStdFile.h:44
gzFile hgzFile
Definition: CStdFile.h:47
StdBuf * pMemory
Definition: CStdFile.h:48

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::Create ( const char *  szFileName,
bool  fCompressed = false,
bool  fExecutable = false,
bool  fMemory = false 
)

Definition at line 49 of file CStdFile.cpp.

References _MAX_PATH, _O_BINARY, c4_gzdopen(), ClearBuffer(), StdStrBuf::Format(), StdStrBuf::getData(), GetWideChar(), hFile, hgzFile, MemoryPtr, ModeWrite, Name, O_CLOEXEC, pMemory, SCopy(), StdThreadCheck::Set(), Status, and thread_check.

Referenced by C4ConfigGeneral::CreateSaveFolder(), C4TableGraph::DumpToFile(), C4UpdatePackage::Execute(), C4Group::ExtractEntry(), main(), C4UpdatePackage::MakeUpdate(), C4Group::Open(), C4Playback::Open(), C4PXSSystem::Save(), CSurface8::Save(), C4Group::Save(), and C4Record::Start().

50 {
51  thread_check.Set();
52  // Set modes
53  ModeWrite=true;
54  // Open in memory?
55  if (fMemory)
56  {
57  if (!(pMemory = new StdBuf())) return false;
58  MemoryPtr = 0;
59 
60  StdStrBuf buf;
61  buf.Format("<%p>", pMemory);
62  SCopy(buf.getData(), Name, _MAX_PATH);
63  }
64  // Open standard file
65  else
66  {
67  SCopy(szFilename,Name,_MAX_PATH);
68  int flags = _O_BINARY|O_CLOEXEC|O_CREAT|O_WRONLY|O_TRUNC;
69 #ifdef _WIN32
70  int mode = _S_IREAD|_S_IWRITE;
71  int fd = _wopen(GetWideChar(Name), flags, mode);
72 #else
73  mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
74  if (fExecutable)
75  mode |= S_IXUSR|S_IXGRP|S_IXOTH;
76  int fd = open(Name, flags, mode);
77 #endif
78  if (fd == -1) return false;
79  if (fCompressed)
80  {
81  if (!(hgzFile = c4_gzdopen(fd,"wb1"))) return false;
82  }
83  else
84  {
85  if (!(hFile = fdopen(fd,"wb"))) return false;
86  }
87  }
88  // Reset buffer
89  ClearBuffer();
90  // Set status
91  Status=true;
92  return true;
93 }
const char * getData() const
Definition: StdBuf.h:442
Definition: StdBuf.h:29
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
FILE * hFile
Definition: CStdFile.h:46
bool Status
Definition: CStdFile.h:43
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
#define _MAX_PATH
#define O_CLOEXEC
bool ModeWrite
Definition: CStdFile.h:52
StdThreadCheck thread_check
Definition: CStdFile.h:53
gzFile ZEXPORT c4_gzdopen(int fd, const char *mode)
Definition: gzio.c:228
void Set()
Definition: StdSync.h:294
#define _O_BINARY
int MemoryPtr
Definition: CStdFile.h:49
char Name[_MAX_PATH+1]
Definition: CStdFile.h:44
gzFile hgzFile
Definition: CStdFile.h:47
void ClearBuffer()
Definition: CStdFile.cpp:234
StdBuf * pMemory
Definition: CStdFile.h:48

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::Default ( )

Definition at line 174 of file CStdFile.cpp.

References BufferLoad, BufferPtr, hFile, hgzFile, MemoryPtr, Name, pMemory, StdThreadCheck::Set(), Status, and thread_check.

175 {
176  Status=false;
177  Name[0]=0;
178  hgzFile=nullptr;
179  hFile=nullptr;
180  pMemory=nullptr;
181  MemoryPtr=0;
183  thread_check.Set();
184  return true;
185 }
int BufferPtr
Definition: CStdFile.h:51
FILE * hFile
Definition: CStdFile.h:46
bool Status
Definition: CStdFile.h:43
StdThreadCheck thread_check
Definition: CStdFile.h:53
int BufferLoad
Definition: CStdFile.h:51
void Set()
Definition: StdSync.h:294
int MemoryPtr
Definition: CStdFile.h:49
char Name[_MAX_PATH+1]
Definition: CStdFile.h:44
gzFile hgzFile
Definition: CStdFile.h:47
StdBuf * pMemory
Definition: CStdFile.h:48

Here is the call graph for this function:

bool CStdFile::Flush ( )
inline

Definition at line 70 of file CStdFile.h.

References SaveBuffer().

Referenced by LogSilent(), C4Record::Rec(), and C4UpdatePackage::WriteLog().

70 { if (ModeWrite && BufferLoad) return SaveBuffer(); else return true; }
bool ModeWrite
Definition: CStdFile.h:52
int BufferLoad
Definition: CStdFile.h:51
bool SaveBuffer()
Definition: CStdFile.cpp:222

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::IsOpen ( ) const
inline

Definition at line 68 of file CStdFile.h.

References hgzFile.

68 { return hFile || hgzFile; }
FILE * hFile
Definition: CStdFile.h:46
gzFile hgzFile
Definition: CStdFile.h:47
int CStdFile::LoadBuffer ( )
protected

Definition at line 213 of file CStdFile.cpp.

References Buffer, BufferLoad, BufferPtr, c4_gzread(), StdThreadCheck::Check(), CStdFileBufSize, hFile, hgzFile, and thread_check.

Referenced by Advance(), and Read().

214 {
216  if (hFile) BufferLoad = fread(Buffer,1,CStdFileBufSize,hFile);
218  BufferPtr=0;
219  return BufferLoad;
220 }
int BufferPtr
Definition: CStdFile.h:51
FILE * hFile
Definition: CStdFile.h:46
const int CStdFileBufSize
Definition: CStdFile.h:26
int ZEXPORT c4_gzread(gzFile file, voidp buf, unsigned len)
Definition: gzio.c:405
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53
int BufferLoad
Definition: CStdFile.h:51
BYTE Buffer[CStdFileBufSize]
Definition: CStdFile.h:50
gzFile hgzFile
Definition: CStdFile.h:47

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::Open ( const char *  szFileName,
bool  fCompressed = false 
)

Definition at line 95 of file CStdFile.cpp.

References _MAX_PATH, _O_BINARY, c4_gzclose(), c4_gzdirect(), c4_gzdopen(), ClearBuffer(), GetWideChar(), hFile, hgzFile, ModeWrite, Name, O_CLOEXEC, SCopy(), StdThreadCheck::Set(), Status, and thread_check.

Referenced by GetFileCRC(), GetFileSHA1(), main(), and C4Playback::Open().

96 {
97  SCopy(szFilename,Name,_MAX_PATH);
98  thread_check.Set();
99  // Set modes
100  ModeWrite=false;
101  int flags = _O_BINARY|O_CLOEXEC|O_RDONLY;
102 #ifdef _WIN32
103  int mode = _S_IREAD|_S_IWRITE;
104  int fd = _wopen(GetWideChar(Name), flags, mode);
105 #else
106  mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
107  int fd = open(Name, flags, mode);
108 #endif
109  if(fd == -1) return false;
110  if (fCompressed)
111  {
112  if (!(hgzFile = c4_gzdopen(fd,"rb"))) { close(fd); return false; }
113  /* Reject uncompressed files */
114  if(c4_gzdirect(hgzFile))
115  {
117  hgzFile = nullptr;
118  return false;
119  }
120  }
121  else
122  {
123  if (!(hFile = fdopen(fd,"rb"))) return false;
124  }
125  // Reset buffer
126  ClearBuffer();
127  // Set status
128  Status=true;
129  return true;
130 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
FILE * hFile
Definition: CStdFile.h:46
bool Status
Definition: CStdFile.h:43
#define _MAX_PATH
#define O_CLOEXEC
bool ModeWrite
Definition: CStdFile.h:52
StdThreadCheck thread_check
Definition: CStdFile.h:53
int ZEXPORT c4_gzclose(gzFile file)
Definition: gzio.c:964
gzFile ZEXPORT c4_gzdopen(int fd, const char *mode)
Definition: gzio.c:228
int ZEXPORT c4_gzdirect(gzFile file)
Definition: gzio.c:919
void Set()
Definition: StdSync.h:294
#define _O_BINARY
char Name[_MAX_PATH+1]
Definition: CStdFile.h:44
gzFile hgzFile
Definition: CStdFile.h:47
void ClearBuffer()
Definition: CStdFile.cpp:234

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::Read ( void *  pBuffer,
size_t  iSize 
)
inlineoverridevirtual

Implements CStdStream.

Definition at line 60 of file CStdFile.h.

References Read().

Referenced by C4Playback::Check(), GetFileCRC(), GetFileSHA1(), main(), C4Playback::NextSequentialChunk(), and Read().

60 { return Read(pBuffer, iSize, nullptr); }
bool Read(void *pBuffer, size_t iSize) override
Definition: CStdFile.h:60
int iSize
Definition: TstC4NetIO.cpp:32

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::Read ( void *  pBuffer,
size_t  iSize,
size_t *  ipFSize 
)

Definition at line 187 of file CStdFile.cpp.

References Buffer, BufferLoad, BufferPtr, StdThreadCheck::Check(), iSize, LoadBuffer(), ModeWrite, and thread_check.

188 {
190  int transfer;
191  if (!pBuffer) return false;
192  if (ModeWrite) return false;
193  BYTE *bypBuffer= (BYTE*) pBuffer;
194  if (ipFSize) *ipFSize = 0;
195  while (iSize>0)
196  {
197  // Valid data in the buffer: Transfer as much as possible
198  if (BufferLoad>BufferPtr)
199  {
200  transfer=std::min<size_t>(BufferLoad-BufferPtr,iSize);
201  memmove(bypBuffer, Buffer+BufferPtr, transfer);
202  BufferPtr+=transfer;
203  bypBuffer+=transfer;
204  iSize-=transfer;
205  if (ipFSize) *ipFSize += transfer;
206  }
207  // Buffer empty: Load
208  else if (LoadBuffer()<=0) return false;
209  }
210  return true;
211 }
int BufferPtr
Definition: CStdFile.h:51
uint8_t BYTE
bool ModeWrite
Definition: CStdFile.h:52
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53
int BufferLoad
Definition: CStdFile.h:51
BYTE Buffer[CStdFileBufSize]
Definition: CStdFile.h:50
int LoadBuffer()
Definition: CStdFile.cpp:213
int iSize
Definition: TstC4NetIO.cpp:32

Here is the call graph for this function:

bool CStdFile::Rewind ( )

Definition at line 275 of file CStdFile.cpp.

References c4_gzrewind(), StdThreadCheck::Check(), ClearBuffer(), hFile, hgzFile, ModeWrite, and thread_check.

276 {
278  if (ModeWrite) return false;
279  ClearBuffer();
280  if (hFile) rewind(hFile);
282  return true;
283 }
FILE * hFile
Definition: CStdFile.h:46
bool ModeWrite
Definition: CStdFile.h:52
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53
int ZEXPORT c4_gzrewind(gzFile file)
Definition: gzio.c:868
gzFile hgzFile
Definition: CStdFile.h:47
void ClearBuffer()
Definition: CStdFile.cpp:234

Here is the call graph for this function:

bool CStdFile::SaveBuffer ( )
protected

Definition at line 222 of file CStdFile.cpp.

References StdBuf::Append(), Buffer, BufferLoad, c4_gzwrite(), StdThreadCheck::Check(), hFile, hgzFile, pMemory, and thread_check.

Referenced by Close(), Flush(), and Write().

223 {
225  int saved = 0;
226  if (hFile) saved=fwrite(Buffer,1,BufferLoad,hFile);
228  if (pMemory) { pMemory->Append(Buffer, BufferLoad); saved = BufferLoad; }
229  if (saved!=BufferLoad) return false;
230  BufferLoad=0;
231  return true;
232 }
FILE * hFile
Definition: CStdFile.h:46
int ZEXPORT c4_gzwrite(gzFile file, voidpc buf, unsigned len)
Definition: gzio.c:570
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53
int BufferLoad
Definition: CStdFile.h:51
void Append(const void *pnData, size_t inSize)
Definition: StdBuf.h:254
BYTE Buffer[CStdFileBufSize]
Definition: CStdFile.h:50
gzFile hgzFile
Definition: CStdFile.h:47
StdBuf * pMemory
Definition: CStdFile.h:48

Here is the call graph for this function:

Here is the caller graph for this function:

int CStdFile::Seek ( long int  offset,
int  whence 
)

Definition at line 308 of file CStdFile.cpp.

References hFile, and hgzFile.

309 {
310  // seek in file by offset and stdio-style SEEK_* constants. Only implemented for uncompressed files.
311  assert(!hgzFile);
312  return fseek(hFile, offset, whence);
313 }
FILE * hFile
Definition: CStdFile.h:46
gzFile hgzFile
Definition: CStdFile.h:47
long int CStdFile::Tell ( )

Definition at line 315 of file CStdFile.cpp.

References hFile, and hgzFile.

316 {
317  // get current file pos. Only implemented for uncompressed files.
318  assert(!hgzFile);
319  return ftell(hFile);
320 }
FILE * hFile
Definition: CStdFile.h:46
gzFile hgzFile
Definition: CStdFile.h:47
bool CStdFile::Write ( const void *  pBuffer,
int  iSize 
)

Definition at line 240 of file CStdFile.cpp.

References Buffer, BufferLoad, StdThreadCheck::Check(), CStdFileBufSize, ModeWrite, SaveBuffer(), and thread_check.

Referenced by C4Playback::Check(), C4UpdatePackage::Execute(), C4Group::ExtractEntry(), LogSilent(), main(), C4UpdatePackage::MakeUpdate(), C4Record::Rec(), C4PXSSystem::Save(), CSurface8::Save(), C4Group::Save(), C4Record::Stop(), C4UpdatePackage::WriteLog(), and WriteString().

241 {
243  int transfer;
244  if (!pBuffer) return false;
245  if (!ModeWrite) return false;
246  const BYTE *bypBuffer= (const BYTE*) pBuffer;
247  while (iSize>0)
248  {
249  // Space in buffer: Transfer as much as possible
251  {
252  transfer=std::min(CStdFileBufSize-BufferLoad,iSize);
253  memcpy(Buffer+BufferLoad,bypBuffer,transfer);
254  BufferLoad+=transfer;
255  bypBuffer+=transfer;
256  iSize-=transfer;
257  }
258  // Buffer full: Save
259  else if (!SaveBuffer()) return false;
260  }
261  return true;
262 }
const int CStdFileBufSize
Definition: CStdFile.h:26
uint8_t BYTE
bool ModeWrite
Definition: CStdFile.h:52
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53
int BufferLoad
Definition: CStdFile.h:51
BYTE Buffer[CStdFileBufSize]
Definition: CStdFile.h:50
bool SaveBuffer()
Definition: CStdFile.cpp:222
int iSize
Definition: TstC4NetIO.cpp:32

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::WriteString ( const char *  szStr)

Definition at line 264 of file CStdFile.cpp.

References StdThreadCheck::Check(), SLen(), thread_check, and Write().

Referenced by C4ConfigGeneral::CreateSaveFolder(), C4TableGraph::DumpToFile(), and C4MessageInput::ProcessCommand().

265 {
267  BYTE nl[2]={0x0D,0x0A};
268  if (!szStr) return false;
269  int size=SLen(szStr);
270  if (!Write((const void*)szStr,size)) return false;
271  if (!Write(nl,2)) return false;
272  return true;
273 }
uint8_t BYTE
size_t SLen(const char *sptr)
Definition: Standard.h:74
bool Write(const void *pBuffer, int iSize)
Definition: CStdFile.cpp:240
void Check()
Definition: StdSync.h:295
StdThreadCheck thread_check
Definition: CStdFile.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

BYTE CStdFile::Buffer[CStdFileBufSize]
protected

Definition at line 50 of file CStdFile.h.

Referenced by LoadBuffer(), Read(), SaveBuffer(), and Write().

int CStdFile::BufferLoad
protected

Definition at line 51 of file CStdFile.h.

Referenced by Advance(), ClearBuffer(), Close(), Default(), LoadBuffer(), Read(), SaveBuffer(), and Write().

int CStdFile::BufferPtr
protected

Definition at line 51 of file CStdFile.h.

Referenced by Advance(), ClearBuffer(), Default(), LoadBuffer(), and Read().

FILE* CStdFile::hFile
protected
gzFile CStdFile::hgzFile
protected
int CStdFile::MemoryPtr
protected

Definition at line 49 of file CStdFile.h.

Referenced by Close(), Create(), and Default().

bool CStdFile::ModeWrite
protected

Definition at line 52 of file CStdFile.h.

Referenced by Advance(), Append(), Close(), Create(), CStdFile(), Open(), Read(), Rewind(), and Write().

char CStdFile::Name[_MAX_PATH+1]

Definition at line 44 of file CStdFile.h.

Referenced by Append(), Close(), Create(), CStdFile(), Default(), and Open().

StdBuf* CStdFile::pMemory
protected

Definition at line 48 of file CStdFile.h.

Referenced by Close(), Create(), CStdFile(), Default(), and SaveBuffer().

bool CStdFile::Status

Definition at line 43 of file CStdFile.h.

Referenced by Append(), Close(), Create(), CStdFile(), Default(), and Open().

StdThreadCheck CStdFile::thread_check
protected

The documentation for this class was generated from the following files: