diff options
Diffstat (limited to 'common/file.cpp')
-rw-r--r-- | common/file.cpp | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/common/file.cpp b/common/file.cpp index f3241cdf6e..85cd75fd51 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -278,68 +278,3 @@ uint32 File::write(const void *ptr, uint32 len) { return len; } - -#define LF 0x0A -#define CR 0x0D - -char *File::gets(void *ptr, uint32 len) { - char *ptr2 = (char *)ptr; - char *res = ptr2; - uint32 read_chars = 1; - - if (_handle == NULL) { - error("File::gets: File is not open!"); - return 0; - } - - if (len == 0 || !ptr) - return NULL; - - // We don't include the newline character(s) in the buffer, and we - // always terminate it - we never read more than len-1 characters. - - // EOF is treated as a line break, unless it was the first character - // that was read. - - // 0 is treated as a line break, even though it should never occur in - // a text file. - - // DOS and Windows use CRLF line breaks - // Unix and OS X use LF line breaks - // Macintosh before OS X uses CR line breaks - - bool first = true; - - while (read_chars < len) { - int c = getc(_handle); - - if (c == EOF) { - if (first) - return NULL; - break; - } - - first = false; - - if (c == 0) - break; - - if (c == LF) - break; - - if (c == CR) { - c = getc(_handle); - // Don't use ungetc() here. It might be slightly more - // elegant, but PalmOS doesn't have it. - if (c != LF && c != EOF) - fseek(_handle, -1, SEEK_CUR); - break; - } - - *ptr2++ = (char) c; - read_chars++; - } - - *ptr2 = 0; - return res; -} |