49 bool CStdFile::Create(
const char *szFilename,
bool fCompressed,
bool fExecutable,
bool fMemory)
70 int mode = _S_IREAD|_S_IWRITE;
73 mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
75 mode |= S_IXUSR|S_IXGRP|S_IXOTH;
76 int fd = open(
Name, flags, mode);
78 if (fd == -1)
return false;
85 if (!(
hFile = fdopen(fd,
"wb")))
return false;
103 int mode = _S_IREAD|_S_IWRITE;
106 mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
107 int fd = open(
Name, flags, mode);
109 if(fd == -1)
return false;
123 if (!(
hFile = fdopen(fd,
"rb")))
return false;
191 if (!pBuffer)
return false;
194 if (ipFSize) *ipFSize = 0;
205 if (ipFSize) *ipFSize += transfer;
244 if (!pBuffer)
return false;
246 const BYTE *bypBuffer= (
const BYTE*) pBuffer;
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;
301 if (
hFile)
return !fseek(
hFile, iOffset, SEEK_CUR);
312 return fseek(
hFile, offset, whence);
328 int mode = _S_IREAD|_S_IWRITE;
329 int fd = _wopen(
GetWideChar(szFilename), flags, mode);
331 mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
332 int fd = open(szFilename, flags, mode);
342 while (rd ==
sizeof buf);
357 if (!pCRC32)
return false;
360 if (!File.
Open(szFilename))
372 iCRC32 = crc32(iCRC32, szData,
iSize);
383 if (!pSHA1)
return false;
386 if (!File.
Open(szFilename))
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
int UncompressedFileSize(const char *szFilename)
bool GetFileSHA1(const char *szFilename, BYTE *pSHA1)
bool GetFileCRC(const char *szFilename, uint32_t *pCRC32)
const int CStdFileBufSize
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
size_t SLen(const char *sptr)
size_t FileSize(const char *fname)
int Seek(long int offset, int whence)
bool Close(StdBuf **ppMemory=nullptr)
BYTE Buffer[CStdFileBufSize]
bool Create(const char *szFileName, bool fCompressed=false, bool fExecutable=false, bool fMemory=false)
bool Write(const void *pBuffer, int iSize)
size_t AccessedEntrySize() const override
bool WriteString(const char *szStr)
bool Advance(int iOffset) override
bool Append(const char *szFilename, bool text=false)
bool Read(void *pBuffer, size_t iSize) override
StdThreadCheck thread_check
bool Open(const char *szFileName, bool fCompressed=false)
void Append(const void *pnData, size_t inSize)
const char * getData() const
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
unsigned int(& digest_type)[5]
void process_bytes(void const *buffer, std::size_t byte_count)
void get_digest(digest_type digest)
int ZEXPORT c4_gzread(gzFile file, voidp buf, unsigned len)
int ZEXPORT c4_gzdirect(gzFile file)
gzFile ZEXPORT c4_gzdopen(int fd, const char *mode)
int ZEXPORT c4_gzrewind(gzFile file)
int ZEXPORT c4_gzclose(gzFile file)
int ZEXPORT c4_gzwrite(gzFile file, voidpc buf, unsigned len)