Commit 1f1b54e7 authored by Jekyll Wu's avatar Jekyll Wu
Browse files

Rename member varibale ion to _fd.

It store an file descriptor, so _fd is more natural than ion.
parent 75017ee5
......@@ -85,14 +85,14 @@ FIXME: There is noticeable decrease in speed, also. Perhaps,
*/
HistoryFile::HistoryFile()
: ion(-1),
: _fd(-1),
length(0),
fileMap(0)
{
if (tmpFile.open())
{
tmpFile.setAutoRemove(true);
ion = tmpFile.handle();
_fd = tmpFile.handle();
}
}
......@@ -109,7 +109,7 @@ void HistoryFile::map()
{
assert( fileMap == 0 );
fileMap = (char*)mmap( 0 , length , PROT_READ , MAP_PRIVATE , ion , 0 );
fileMap = (char*)mmap( 0 , length , PROT_READ , MAP_PRIVATE , _fd , 0 );
//if mmap'ing fails, fall back to the read-lseek combination
if ( fileMap == MAP_FAILED )
......@@ -142,8 +142,8 @@ void HistoryFile::add(const unsigned char* bytes, int len)
int rc = 0;
rc = KDE_lseek(ion,length,SEEK_SET); if (rc < 0) { perror("HistoryFile::add.seek"); return; }
rc = write(ion,bytes,len); if (rc < 0) { perror("HistoryFile::add.write"); return; }
rc = KDE_lseek(_fd,length,SEEK_SET); if (rc < 0) { perror("HistoryFile::add.seek"); return; }
rc = write(_fd,bytes,len); if (rc < 0) { perror("HistoryFile::add.write"); return; }
length += rc;
}
......@@ -168,8 +168,8 @@ void HistoryFile::get(unsigned char* bytes, int len, int loc)
if (loc < 0 || len < 0 || loc + len > length)
fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc);
rc = KDE_lseek(ion,loc,SEEK_SET); if (rc < 0) { perror("HistoryFile::get.seek"); return; }
rc = read(ion,bytes,len); if (rc < 0) { perror("HistoryFile::get.read"); return; }
rc = KDE_lseek(_fd,loc,SEEK_SET); if (rc < 0) { perror("HistoryFile::get.seek"); return; }
rc = read(_fd,bytes,len); if (rc < 0) { perror("HistoryFile::get.read"); return; }
}
}
......
......@@ -63,7 +63,7 @@ public:
private:
int ion;
int _fd;
int length;
KTemporaryFile tmpFile;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment