mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Add a file getline() function to parse files one line at a time
This commit is contained in:
@@ -242,6 +242,8 @@ FILE *fopen(const char *filename, const char *mode);
|
||||
size_t fread(void *buf, size_t elementSize, size_t count, FILE *f);
|
||||
size_t fwrite(const void *buf, size_t elementSize, size_t count, FILE *f);
|
||||
|
||||
std::string getline(FILE *f);
|
||||
|
||||
uint64_t ftell64(FILE *f);
|
||||
void fseek64(FILE *f, uint64_t offset, int origin);
|
||||
|
||||
|
||||
@@ -249,6 +249,26 @@ FILE *fopen(const char *filename, const char *mode)
|
||||
return ::fopen(filename, mode);
|
||||
}
|
||||
|
||||
string getline(FILE *f)
|
||||
{
|
||||
string ret;
|
||||
|
||||
while(!FileIO::feof(f))
|
||||
{
|
||||
char c = (char)::fgetc(f);
|
||||
|
||||
if(FileIO::feof(f))
|
||||
break;
|
||||
|
||||
if(c != 0 && c != '\n')
|
||||
ret.push_back(c);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t fread(void *buf, size_t elementSize, size_t count, FILE *f)
|
||||
{
|
||||
return ::fread(buf, elementSize, count, f);
|
||||
|
||||
@@ -343,6 +343,26 @@ FILE *fopen(const char *filename, const char *mode)
|
||||
return ret;
|
||||
}
|
||||
|
||||
string getline(FILE *f)
|
||||
{
|
||||
string ret;
|
||||
|
||||
while(!FileIO::feof(f))
|
||||
{
|
||||
char c = (char)::fgetc(f);
|
||||
|
||||
if(FileIO::feof(f))
|
||||
break;
|
||||
|
||||
if(c != 0 && c != '\n')
|
||||
ret.push_back(c);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t fread(void *buf, size_t elementSize, size_t count, FILE *f)
|
||||
{
|
||||
return ::fread(buf, elementSize, count, f);
|
||||
|
||||
Reference in New Issue
Block a user