本文整理汇总了C++中TextStream::OpenFile方法的典型用法代码示例。如果您正苦于以下问题:C++ TextStream::OpenFile方法的具体用法?C++ TextStream::OpenFile怎么用?C++ TextStream::OpenFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextStream
的用法示例。
在下文中一共展示了TextStream::OpenFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TextStream
char *
Downloader::GetResponseText (const char *partname, gint64 *size)
{
LOG_DOWNLOADER ("Downloader::GetResponseText (%s, %p)\n", partname, size);
TextStream *stream;
char buffer[4096];
GByteArray *buf;
struct stat st;
ssize_t nread;
char *data;
char *path;
if (!(path = GetDownloadedFilename (partname)))
return NULL;
if (g_stat (path, &st) == -1) {
g_free (path);
return NULL;
}
if (st.st_size > 0) {
stream = new TextStream ();
if (!stream->OpenFile (path, true)) {
delete stream;
g_free (path);
return NULL;
}
g_free (path);
buf = g_byte_array_new ();
while ((nread = stream->Read (buffer, sizeof (buffer))) > 0)
g_byte_array_append (buf, (const guint8 *) buffer, nread);
*size = buf->len;
g_byte_array_append (buf, (const guint8 *) "", 1);
data = (char *) buf->data;
g_byte_array_free (buf, false);
delete stream;
} else {
data = g_strdup ("");
*size = 0;
}
return data;
}
示例2: main
int main (int argc, const char* argv[])
{
if (argc != 2) {
printf ("pass in an ASX file to parse.\n");
return -1;
}
TextStream *ts = new TextStream ();
printf ("opening the file: %s\n", argv [1]);
ts->OpenFile (argv [1], true);
AsxParserInternal *asx = new AsxParserInternal (ts);
asx->run ();
}