author | unc0rr |
Sat, 08 Dec 2012 20:23:13 +0400 | |
branch | flibqtfrontend |
changeset 8275 | e0a134d890e7 |
parent 8100 | 0e6fadf81a2c |
permissions | -rw-r--r-- |
8100 | 1 |
#include <stdlib.h> |
2 |
||
3 |
#include "physfsfgets.h" |
|
4 |
||
5 |
char * PHYSFS_fgets(char * str, int size, PHYSFS_file * f) |
|
6 |
{ |
|
7 |
int i = 0; |
|
8 |
char c; |
|
9 |
||
10 |
if(size <= 0 || PHYSFS_eof(f)) |
|
11 |
return NULL; |
|
12 |
||
13 |
do |
|
14 |
{ |
|
15 |
if (PHYSFS_readBytes(f, &c, 1) < 1) |
|
16 |
break; |
|
17 |
||
18 |
str[i] = c; |
|
19 |
++i; |
|
20 |
} while(c != '\n' && i < size - 1); |
|
21 |
||
22 |
str[i] = '\0'; |
|
23 |
if (i == 0) |
|
24 |
return NULL; |
|
25 |
else |
|
26 |
return str; |
|
27 |
} |