Reading file backwards
#7

Quote:
Originally Posted by Logic_
View Post
You can try experimenting with something like:

PHP Code:
// Open "file.txt" in "read only" mode
new File:handle fopen("file.txt"io_read);
 
// If "file.txt" is open
if(handle) {
    
// Jump to the last byte of "file.txt", and print its position
    
printf("End of file position: %d"fseek(handle0seek_end));
    
fclose(handle);

( Taken from SA-MP wiki https://sampwiki.blast.hk/wiki/Fseek )
I don't know if I could use this for my log file because i need something like:
Code:
while(fread(handle, data))
but read it upwards(last 30 lines).

This is my current load function that loads file string normally from begining
PHP Code:
function givendmg_load(playerid){
    new 
f[64]; format(f64givendmg_fileGetName(playerid));
    new 
Data[256], x=0arrCoords[6][64];
    new 
File:handle fopen(fio_read);
    
    if(!
fexist(f)) return printf("File %s ne postoji te se sistem nije ucitao"f);
    
    while(
fread(handleData)){
        
split(DataarrCoords',');
        
strmid(givendmgInfo[playerid][x][dmgDate], arrCoords[0], 0strlen(arrCoords[0]));
        
strmid(givendmgInfo[playerid][x][dmgTime], arrCoords[1], 0strlen(arrCoords[1]));
        
strmid(givendmgInfo[playerid][x][dmgGivenTo], arrCoords[2], 0strlen(arrCoords[2]));
        
strmid(givendmgInfo[playerid][x][dmgGivenBy], arrCoords[3], 0strlen(arrCoords[3]));
        
givendmgInfo[playerid][x][dmgAmount] = strval(arrCoords[4]);
        
givendmgInfo[playerid][x][dmgWeapon] = strval(arrCoords[5]);
        
x++;
    }
    
fclose(handle);
    return 
1;

Can anyone give me an example how to reverse fread()
Reply


Messages In This Thread
Reading file backwards - by Suttix - 28.03.2019, 18:18
Re: Reading file backwards - by Suttix - 28.03.2019, 21:02
Re: Reading file backwards - by TokicMajstor - 28.03.2019, 23:00
Re: Reading file backwards - by Suttix - 29.03.2019, 00:23
Re: Reading file backwards - by introzen - 29.03.2019, 08:44
Re: Reading file backwards - by Logic_ - 29.03.2019, 09:24
Re: Reading file backwards - by Suttix - 29.03.2019, 11:24
Re: Reading file backwards - by Suttix - 29.03.2019, 11:59
Re: Reading file backwards - by NaS - 29.03.2019, 13:59
Re: Reading file backwards - by Suttix - 29.03.2019, 15:17

Forum Jump:


Users browsing this thread: 2 Guest(s)