Quote:
Originally Posted by edon1337
How would I check that?
|
PHP Code:
//Open file for update (reading and writing).
new iFile = fopen( "file.txt" , "r+" );
//Buffer to read 1 single byte.
new bytVal[ 1 ];
//Buffer for new line to write.
new szNewLine[ 32 ];
//Seek to the end of file - 1 (since we want to read the last byte).
fseek( iFile , -1 , SEEK_END );
//Read byte.
fread_raw( iFile , bytVal , sizeof( bytVal ) , BLOCK_BYTE );
//Seek to the end of the file for writing new line.
fseek( iFile , 0 , SEEK_END );
//Format new line. Prefix with '^n' if current last byte is not a new line byte.
formatex( szNewLine , charsmax( szNewLine ) , "%sNew line" , ( bytVal[ 0 ] == 10 ) ? "" : "^n" );
//Write line to file.
fputs( iFile , szNewLine );
//Close file.
fclose( iFile );
__________________