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 ()
 
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 39 of file CStdFile.h.

Constructor & Destructor Documentation

CStdFile::CStdFile ( )

Definition at line 36 of file CStdFile.cpp.

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

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

Here is the call graph for this function:

CStdFile::~CStdFile ( )

Definition at line 48 of file CStdFile.cpp.

References Close().

49 {
50  Close();
51 }
bool Close(StdBuf **ppMemory=nullptr)
Definition: CStdFile.cpp:155

Here is the call graph for this function:

Member Function Documentation

size_t CStdFile::AccessedEntrySize ( ) const
overridevirtual

Implements CStdStream.

Definition at line 351 of file CStdFile.cpp.

References FileSize(), hFile, and hgzFile.

352 {
353  if (hFile)
354  return FileSize(fileno(hFile));
355  assert(!hgzFile);
356  return 0;
357 }
FILE * hFile
Definition: CStdFile.h:47
size_t FileSize(const char *szFilename)
Definition: StdFile.cpp:448
gzFile hgzFile
Definition: CStdFile.h:48

Here is the call graph for this function:

bool CStdFile::Advance ( int  iOffset)
overridevirtual

Implements CStdStream.

Definition at line 289 of file CStdFile.cpp.

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

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

Here is the call graph for this function:

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

Definition at line 136 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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void CStdFile::ClearBuffer ( )
protected

Definition at line 238 of file CStdFile.cpp.

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

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

239 {
242 }
int BufferPtr
Definition: CStdFile.h:52
void Check()
Definition: StdSync.h:296
StdThreadCheck thread_check
Definition: CStdFile.h:54
int BufferLoad
Definition: CStdFile.h:52

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 155 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().

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

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 53 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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::Default ( )

Definition at line 178 of file CStdFile.cpp.

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

179 {
180  Status=false;
181  Name[0]=0;
182  hgzFile=nullptr;
183  hFile=nullptr;
184  pMemory=nullptr;
185  MemoryPtr=0;
187  thread_check.Set();
188  return true;
189 }
int BufferPtr
Definition: CStdFile.h:52
FILE * hFile
Definition: CStdFile.h:47
bool Status
Definition: CStdFile.h:44
StdThreadCheck thread_check
Definition: CStdFile.h:54
int BufferLoad
Definition: CStdFile.h:52
void Set()
Definition: StdSync.h:295
int MemoryPtr
Definition: CStdFile.h:50
char Name[_MAX_PATH+1]
Definition: CStdFile.h:45
gzFile hgzFile
Definition: CStdFile.h:48
StdBuf * pMemory
Definition: CStdFile.h:49

Here is the call graph for this function:

bool CStdFile::Flush ( )
inline

Definition at line 71 of file CStdFile.h.

References SaveBuffer().

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

71 { if (ModeWrite && BufferLoad) return SaveBuffer(); else return true; }
bool ModeWrite
Definition: CStdFile.h:53
int BufferLoad
Definition: CStdFile.h:52
bool SaveBuffer()
Definition: CStdFile.cpp:226

Here is the call graph for this function:

Here is the caller graph for this function:

bool CStdFile::IsOpen ( ) const
inline

Definition at line 69 of file CStdFile.h.

References hgzFile.

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

Definition at line 217 of file CStdFile.cpp.

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

Referenced by Advance(), and Read().

218 {
220  if (hFile) BufferLoad = fread(Buffer,1,CStdFileBufSize,hFile);
222  BufferPtr=0;
223  return BufferLoad;
224 }
int BufferPtr
Definition: CStdFile.h:52
FILE * hFile
Definition: CStdFile.h:47
const int CStdFileBufSize
Definition: CStdFile.h:27
int ZEXPORT c4_gzread(gzFile file, voidp buf, unsigned len)
Definition: gzio.c:405
void Check()
Definition: StdSync.h:296
StdThreadCheck thread_check
Definition: CStdFile.h:54
int BufferLoad
Definition: CStdFile.h:52
BYTE Buffer[CStdFileBufSize]
Definition: CStdFile.h:51
gzFile hgzFile
Definition: CStdFile.h:48

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 99 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().

100 {
101  SCopy(szFilename,Name,_MAX_PATH);
102  thread_check.Set();
103  // Set modes
104  ModeWrite=false;
105  int flags = _O_BINARY|O_CLOEXEC|O_RDONLY;
106 #ifdef _WIN32
107  int mode = _S_IREAD|_S_IWRITE;
108  int fd = _wopen(GetWideChar(Name), flags, mode);
109 #else
110  mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
111  int fd = open(Name, flags, mode);
112 #endif
113  if(fd == -1) return false;
114  if (fCompressed)
115  {
116  if (!(hgzFile = c4_gzdopen(fd,"rb"))) { close(fd); return false; }
117  /* Reject uncompressed files */
118  if(c4_gzdirect(hgzFile))
119  {
121  hgzFile = nullptr;
122  return false;
123  }
124  }
125  else
126  {
127  if (!(hFile = fdopen(fd,"rb"))) return false;
128  }
129  // Reset buffer
130  ClearBuffer();
131  // Set status
132  Status=true;
133  return true;
134 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
FILE * hFile
Definition: CStdFile.h:47
bool Status
Definition: CStdFile.h:44
#define _MAX_PATH
#define O_CLOEXEC
bool ModeWrite
Definition: CStdFile.h:53
StdThreadCheck thread_check
Definition: CStdFile.h:54
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:295
#define _O_BINARY
char Name[_MAX_PATH+1]
Definition: CStdFile.h:45
gzFile hgzFile
Definition: CStdFile.h:48
void ClearBuffer()
Definition: CStdFile.cpp:238

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 61 of file CStdFile.h.

References Read().

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

61 { return Read(pBuffer, iSize, 0); }
bool Read(void *pBuffer, size_t iSize) override
Definition: CStdFile.h:61
int iSize
Definition: TstC4NetIO.cpp:35

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 191 of file CStdFile.cpp.

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

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

Here is the call graph for this function:

bool CStdFile::Rewind ( )

Definition at line 279 of file CStdFile.cpp.

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

280 {
282  if (ModeWrite) return false;
283  ClearBuffer();
284  if (hFile) rewind(hFile);
286  return true;
287 }
FILE * hFile
Definition: CStdFile.h:47
bool ModeWrite
Definition: CStdFile.h:53
void Check()
Definition: StdSync.h:296
StdThreadCheck thread_check
Definition: CStdFile.h:54
int ZEXPORT c4_gzrewind(gzFile file)
Definition: gzio.c:868
gzFile hgzFile
Definition: CStdFile.h:48
void ClearBuffer()
Definition: CStdFile.cpp:238

Here is the call graph for this function:

bool CStdFile::SaveBuffer ( )
protected

Definition at line 226 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().

227 {
229  int saved = 0;
230  if (hFile) saved=fwrite(Buffer,1,BufferLoad,hFile);
232  if (pMemory) { pMemory->Append(Buffer, BufferLoad); saved = BufferLoad; }
233  if (saved!=BufferLoad) return false;
234  BufferLoad=0;
235  return true;
236 }
FILE * hFile
Definition: CStdFile.h:47
int ZEXPORT c4_gzwrite(gzFile file, voidpc buf, unsigned len)
Definition: gzio.c:570
void Check()
Definition: StdSync.h:296
StdThreadCheck thread_check
Definition: CStdFile.h:54
int BufferLoad
Definition: CStdFile.h:52
void Append(const void *pnData, size_t inSize)
Definition: StdBuf.h:262
BYTE Buffer[CStdFileBufSize]
Definition: CStdFile.h:51
gzFile hgzFile
Definition: CStdFile.h:48
StdBuf * pMemory
Definition: CStdFile.h:49

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 312 of file CStdFile.cpp.

References hFile, and hgzFile.

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

Definition at line 319 of file CStdFile.cpp.

References hFile, and hgzFile.

320 {
321  // get current file pos. Only implemented for uncompressed files.
322  assert(!hgzFile);
323  return ftell(hFile);
324 }
FILE * hFile
Definition: CStdFile.h:47
gzFile hgzFile
Definition: CStdFile.h:48
bool CStdFile::Write ( const void *  pBuffer,
int  iSize 
)

Definition at line 244 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().

245 {
247  int transfer;
248  if (!pBuffer) return false;
249  if (!ModeWrite) return false;
250  const BYTE *bypBuffer= (const BYTE*) pBuffer;
251  while (iSize>0)
252  {
253  // Space in buffer: Transfer as much as possible
255  {
256  transfer=std::min(CStdFileBufSize-BufferLoad,iSize);
257  memcpy(Buffer+BufferLoad,bypBuffer,transfer);
258  BufferLoad+=transfer;
259  bypBuffer+=transfer;
260  iSize-=transfer;
261  }
262  // Buffer full: Save
263  else if (!SaveBuffer()) return false;
264  }
265  return true;
266 }
const int CStdFileBufSize
Definition: CStdFile.h:27
uint8_t BYTE
bool ModeWrite
Definition: CStdFile.h:53
void Check()
Definition: StdSync.h:296
StdThreadCheck thread_check
Definition: CStdFile.h:54
int BufferLoad
Definition: CStdFile.h:52
BYTE Buffer[CStdFileBufSize]
Definition: CStdFile.h:51
bool SaveBuffer()
Definition: CStdFile.cpp:226
int iSize
Definition: TstC4NetIO.cpp:35

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 268 of file CStdFile.cpp.

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

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

269 {
271  BYTE nl[2]={0x0D,0x0A};
272  if (!szStr) return false;
273  int size=SLen(szStr);
274  if (!Write((const void*)szStr,size)) return false;
275  if (!Write(nl,2)) return false;
276  return true;
277 }
uint8_t BYTE
size_t SLen(const char *sptr)
Definition: Standard.h:78
bool Write(const void *pBuffer, int iSize)
Definition: CStdFile.cpp:244
void Check()
Definition: StdSync.h:296
StdThreadCheck thread_check
Definition: CStdFile.h:54

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 51 of file CStdFile.h.

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

int CStdFile::BufferLoad
protected

Definition at line 52 of file CStdFile.h.

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

int CStdFile::BufferPtr
protected

Definition at line 52 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 50 of file CStdFile.h.

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

bool CStdFile::ModeWrite
protected

Definition at line 53 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 45 of file CStdFile.h.

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

StdBuf* CStdFile::pMemory
protected

Definition at line 49 of file CStdFile.h.

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

bool CStdFile::Status

Definition at line 44 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: