Fix macro parser of random file reading
This commit is contained in:
parent
8a29497f7d
commit
497bf8d0c9
@ -28,14 +28,19 @@
|
|||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
// GetRandomLine() - Get random line from file
|
||||||
|
// 1st parameter: buffer to store string, don't changed if file can't opened.
|
||||||
|
// 2nd parameter: size of buffer
|
||||||
|
// 3rd parameter: file name
|
||||||
|
// Return first parameter.
|
||||||
char* GetRandomLine(char* __buf, size_t __bufsize, const char* file)
|
char* GetRandomLine(char* __buf, size_t __bufsize, const char* file)
|
||||||
{
|
{
|
||||||
Path indexfile;
|
Path indexfile;
|
||||||
Path __file;
|
Path __file;
|
||||||
|
|
||||||
|
if( (__buf==NULL) || (__file==NULL) ) return __buf;
|
||||||
|
|
||||||
strxcpy(__file, file, sizeof(Path));
|
strxcpy(__file, file, sizeof(Path));
|
||||||
strxcpy(__buf, "", __bufsize);
|
|
||||||
strschg_environ(__file);
|
strschg_environ(__file);
|
||||||
|
|
||||||
replaceextension(indexfile, __file, ".sdx");
|
replaceextension(indexfile, __file, ".sdx");
|
||||||
@ -43,6 +48,7 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* file)
|
|||||||
gfile fp(AddPath(CFG->goldpath, __file), "rb", CFG->sharemode);
|
gfile fp(AddPath(CFG->goldpath, __file), "rb", CFG->sharemode);
|
||||||
if (fp.isopen())
|
if (fp.isopen())
|
||||||
{
|
{
|
||||||
|
strxcpy(__buf, "", __bufsize);
|
||||||
fp.SetvBuf(NULL, _IOFBF, 32000);
|
fp.SetvBuf(NULL, _IOFBF, 32000);
|
||||||
|
|
||||||
// Check if index exists or if it is older than the textfile
|
// Check if index exists or if it is older than the textfile
|
||||||
|
Reference in New Issue
Block a user