branch | flibqtfrontend |
changeset 8100 | 0e6fadf81a2c |
8097:59a8feebec2c | 8100:0e6fadf81a2c |
---|---|
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 } |