Chinaunix首页 | 论坛 | 博客
  • 博客访问: 662512
  • 博文数量: 137
  • 博客积分: 7000
  • 博客等级: 少将
  • 技术积分: 1335
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-23 15:18
文章分类

全部博文(137)

文章存档

2010年(2)

2009年(2)

2008年(2)

2007年(30)

2006年(99)

2005年(2)

我的朋友

分类: 系统运维

2006-03-23 17:48:18

在xpcom/obsolete/nsFileStream.cpp文件中定义了这个方法,也许会有用。
PRBool nsRandomAccessInputStream::readline(char* s, PRInt32 n)
// This will truncate if the buffer is too small. Result will always be null-terminated.
//----------------------------------------------------------------------------------------
{
PRBool bufferLargeEnough = PR_TRUE; // result
if (!s || !n)
return PR_TRUE;

PRIntn position = tell();
if (position < 0)
return PR_FALSE;
PRInt32 bytesRead = read(s, n - 1);
if (failed())
return PR_FALSE;
s[bytesRead] = '
char* tp = strpbrk(s, "\n\r");
if (tp)
{
TidyEndOfLine(tp);
bytesRead = (tp - s);
}
else if (!eof() && n-1 == bytesRead)
bufferLargeEnough = PR_FALSE;
position += bytesRead;
seek(position);
return bufferLargeEnough;
} // nsRandomAccessInputStream::readline
阅读(1220) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~