95 bool SysFile::open(
const char *name,
int openFlags,
int openMode,
int shareMode)
102 fileHandle = _sopen(name, openFlags|_O_NOINHERIT|_O_BINARY, shareMode, openMode);
180 buffer = (
char *)malloc(length);
340 return bytesRead > 0 ? true :
false;
365 bytesRead += blocksize;
372 int blockRead = _read(
fileHandle, buf + bytesRead, (
unsigned int)len);
379 return bytesRead > 0 ? true :
false;
390 bytesRead += blockRead;
412 return _write(
fileHandle, data, (
unsigned int)length);
417 int bytesWritten = 0;
421 int justWritten = _write(
fileHandle, data, (
unsigned int)segmentSize);
423 if (justWritten <= 0)
427 length -= justWritten;
428 bytesWritten += justWritten;
446 bool SysFile::write(
const char *data,
size_t len,
size_t &bytesWritten)
484 bytesWritten = written;
518 if ((
flags & _O_APPEND) != 0)
536 bytesWritten = written;
549 bytesWritten = written;
558 return write(&ch, 1, len);
572 return read(&ch, 1, len);
577 return write(data, strlen(data), len);
605 bytesWritten += termlen;
612 bool SysFile::gets(
char *buffer,
size_t bufferLen,
size_t &bytesRead)
615 for (i = 0; i < bufferLen - 1; i++)
636 if (i >= 1 &&
buffer[i - 1] ==
'\r')
699 if (!
seek(start, SEEK_SET, start))
786 endPosition = startPosition;
798 endPosition = startPosition;
809 endPosition = startPosition;
815 while (offset < bytesRead)
819 if (
buffer[offset] ==
'\n')
827 endPosition = startPosition + offset + 1;
837 startPosition += bytesRead;
867 position = _lseeki64(
fileHandle, location, SEEK_SET);
913 position = _lseeki64(
fileHandle, offset, SEEK_SET);
917 position = _lseeki64(
fileHandle, offset, SEEK_CUR);
921 position = _lseeki64(
fileHandle, offset, SEEK_END);
976 struct _stati64 fileInfo;
980 if (fileInfo.st_dev == 0)
982 size = fileInfo.st_size;
1005 struct _stati64 fileInfo;
1006 if (_stati64(name, &fileInfo) == 0)
1009 if ((fileInfo.st_mode & _S_IFREG) != 0)
1011 size = fileInfo.st_size;
1038 struct _stati64 fileInfo;
1042 if ((fileInfo.st_mode & _S_IFREG) != 0)
1044 time = ctime(&fileInfo.st_mtime);
1063 struct _stati64 fileInfo;
1064 if (_stati64(name, &fileInfo) == 0)
1067 if ((fileInfo.st_mode & (_S_IFREG | _S_IFDIR)) != 0)
1069 time = ctime(&fileInfo.st_mtime);
1095 struct _stati64 fileInfo;
1099 if ((fileInfo.st_mode & _S_IFCHR) != 0)
1105 if ((fileInfo.st_mode & _S_IWRITE) != 0)
1110 if ((fileInfo.st_mode & _S_IREAD) != 0)
1115 if ((fileInfo.st_mode & _S_IFIFO) != 0)
1150 setbuf(stdout, NULL);
1166 setbuf(stderr, NULL);
1185 return (_kbhit() != 0) ? 1 : 0;
bool putLine(const char *buffer, size_t len, size_t &bytesWritten)
bool gets(char *buffer, size_t len, size_t &bytesRead)
bool nextLine(size_t &bytesRead)
bool getSize(int64_t &size)
bool seek(int64_t offset, int direction, int64_t &position)
bool seekForwardLines(int64_t startPosition, int64_t &lineCount, int64_t &endPosition)
@ LINE_POSITIONING_BUFFER
int writeData(const char *data, size_t length)
bool puts(const char *data, size_t &bytesWritten)
bool getPosition(int64_t &position)
void setBuffering(bool buffer, size_t length)
bool getTimeStamp(const char *&time)
bool open(const char *name, int openFlags, int openMode, int shareMode)
bool read(char *buf, size_t len, size_t &bytesRead)
bool countLines(int64_t &count)
bool write(const char *data, size_t len, size_t &bytesWritten)
bool setPosition(int64_t location, int64_t &position)