53 #include <sys/types.h>
55 #include <sys/ioctl.h>
62 #if defined( HAVE_SYS_FILIO_H )
63 # include <sys/filio.h>
66 #if defined(__APPLE__) && defined(__MACH__)
67 # define lseek64 lseek
82 # define lstat64 lstat
83 # define fstat64 fstat
129 bool SysFile::open(
const char *name,
int openFlags,
int openMode,
int shareMode)
134 fileHandle = ::open64(name, openFlags, (mode_t)openMode);
238 buffer = (
char *)malloc(length);
401 return bytesRead > 0 ? true :
false;
426 bytesRead += blocksize;
441 return bytesRead > 0 ? true :
false;
452 bytesRead += blockRead;
509 bytesWritten = written;
543 if ((
flags & O_APPEND) != 0)
561 bytesWritten = written;
574 bytesWritten = written;
583 return write(&ch, 1, len);
596 return read(&ch, 1, len);
601 return write(data, strlen(data), len);
621 if (!
write(mybuffer, len, bytesWritten))
629 bytesWritten += termlen;
639 for (i = 0; i < bufferLen - 1; i++)
644 if (!this->
read(mybuffer + i, 1, len))
655 if (mybuffer[i] ==
'\n')
660 if (i >= 1 && mybuffer[i - 1] ==
'\r')
723 if (!
seek(start, SEEK_SET, start))
794 if (mybuffer == NULL)
810 endPosition = startPosition;
815 if (!
read(mybuffer, readLength, bytesRead))
822 endPosition = startPosition;
833 endPosition = startPosition;
839 while (offset < bytesRead)
843 if (mybuffer[offset] ==
'\n')
851 endPosition = startPosition + offset + 1;
861 startPosition += bytesRead;
891 position = lseek64(
fileHandle, location, SEEK_SET);
937 position = lseek64(
fileHandle, offset, SEEK_SET);
941 position = lseek64(
fileHandle, offset, SEEK_CUR);
945 position = lseek64(
fileHandle, offset, SEEK_END);
1000 struct stat64 fileInfo;
1004 if ((fileInfo.st_mode & S_IFREG) != 0)
1006 size = fileInfo.st_size;
1029 struct stat64 fileInfo;
1030 if (stat64(name, &fileInfo) == 0)
1033 if ((fileInfo.st_mode & S_IFREG) != 0)
1035 size = fileInfo.st_size;
1062 struct stat64 fileInfo;
1066 if ((fileInfo.st_mode & S_IFREG) != 0)
1068 time = ctime(&fileInfo.st_mtime);
1087 struct stat64 fileInfo;
1088 if (stat64(name, &fileInfo) == 0)
1091 if ((fileInfo.st_mode & (S_IFREG | S_IFDIR)) != 0)
1093 time = ctime(&fileInfo.st_mtime);
1119 struct stat64 fileInfo;
1123 if ((fileInfo.st_mode & S_IFCHR) != 0)
1129 if ((fileInfo.st_mode & S_IWRITE) != 0)
1134 if ((fileInfo.st_mode & S_IREAD) != 0)
1139 if ((fileInfo.st_mode & S_IFIFO) != 0)
1160 setbuf(stdin, NULL);
1178 setbuf(stdout, NULL);
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
static const int stdinHandle
static const int stderrHandle
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)
static const int stdoutHandle
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)