本文整理汇总了C++中FileSystem::ReadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::ReadFile方法的具体用法?C++ FileSystem::ReadFile怎么用?C++ FileSystem::ReadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::ReadFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: choosePalette
IDataSource * choosePalette()
{
FileSystem * filesys = FileSystem::get_instance();
GtkWidget *file_sel;
gchar *filename;
gboolean selected = FALSE;
file_sel = gtk_file_selection_new( "Choose a Palette" );
gtk_window_set_modal( GTK_WINDOW( file_sel ), TRUE );
gtk_signal_connect( GTK_OBJECT( file_sel ), "destroy",
GTK_SIGNAL_FUNC( file_sel_delete ), &file_sel );
gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->cancel_button ), "clicked", GTK_SIGNAL_FUNC( file_sel_delete ), &file_sel );
gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->ok_button ), "clicked", GTK_SIGNAL_FUNC( file_selected ), &selected );
gtk_widget_show( file_sel );
while( ( ! selected ) && ( file_sel ) )
gtk_main_iteration();
/* canceled or window was closed */
if( ! selected )
return 0;
/* ok */
filename = g_strdup( gtk_file_selection_get_filename( GTK_FILE_SELECTION( file_sel ) ) );
gtk_widget_destroy( file_sel );
IDataSource * ds = filesys->ReadFile(filename);
return ds;
}
示例2: exists
bool DirFile::exists(const std::string& name)
{
FileSystem* filesys = FileSystem::get_instance();
IDataSource* ids = filesys->ReadFile(path + name);
if (!ids) return false;
delete ids;
return true;
}
示例3: getSize
uint32 DirFile::getSize(const std::string& name)
{
FileSystem* filesys = FileSystem::get_instance();
IDataSource* ids = filesys->ReadFile(path + name);
if (!ids) return 0;
uint32 size = ids->getSize();
delete ids;
return size;
}
示例4: getObject
uint8* DirFile::getObject(const std::string& name, uint32* sizep)
{
FileSystem* filesys = FileSystem::get_instance();
IDataSource* ids = filesys->ReadFile(path + name);
if (!ids) return 0;
uint32 size = ids->getSize();
if (size == 0) return 0;
uint8* buf = new uint8[size];
ids->read(buf, size);
delete ids;
if (sizep) *sizep = size;
return buf;
}
示例5: Transfer
bool TransportHandlerFile::Transfer(TransportInfo* pTInfo, bool& bStateComplete)
{
using namespace EA::WebKit;
bool bResult = true;
FileInfo* pFileInfo = (FileInfo*)pTInfo->mTransportHandlerData;
EAW_ASSERT(pFileInfo != NULL);
char* pBuffer = GetFileDownloadBuffer();
if((pFileInfo->mFileObject != FileSystem::kFileObjectInvalid) && (pBuffer))
{
FileSystem* pFS = GetFileSystem();
EAW_ASSERT(pFS != NULL);
if(pFileInfo->mbRead) // If we need to read a file from disk and send it to the TransportServer.
{
if(pFileInfo->mFileSize < 0) // If this is the first time through...
{
pFileInfo->mFileSize = pFS->GetFileSize(pFileInfo->mFileObject);
pTInfo->mpTransportServer->SetExpectedLength(pTInfo, pFileInfo->mFileSize);
// pTInfo->mpTransportServer->SetEncoding(pTInfo, char* pEncoding);
// pTInfo->mpTransportServer->SetMimeType(pTInfo);
// pTInfo->mpTransportServer->HeadersReceived(pTInfo);
}
// To consider: Enable reading more than just one chunk at a time. However, by doing
// so we could block the current thread for an undesirable period of time.
const int64_t size = pFS->ReadFile(pFileInfo->mFileObject, pBuffer, kFileDownloadBufferSize);
if(size >= 0) // If no error...
{
if(size > 0)
pTInfo->mpTransportServer->DataReceived(pTInfo, pBuffer, size);
else
{
bStateComplete = true;
bResult = true;
}
}
else
{
bStateComplete = true;
bResult = false;
}
}
else // Else we need to read a file from the TransportServer and write it to disk.
{
const int64_t size = pTInfo->mpTransportServer->ReadData(pTInfo, pBuffer, kFileDownloadBufferSize);
if(size >= 0) // If no error...
{
if(size > 0)
{
if(!pFS->WriteFile(pFileInfo->mFileObject, pBuffer, size))
{
bStateComplete = true;
bResult = false;
}
}
else
{
bStateComplete = true;
bResult = true;
}
}
else
{
bStateComplete = true;
bResult = false;
}
}
}
else
{
bStateComplete = true;
bResult = false;
}
// For now, set it to either 200 (OK) or 404 (not found).
if(bResult)
pTInfo->mResultCode = 200;
else
pTInfo->mResultCode = 404;
if(bStateComplete)
pTInfo->mpTransportServer->DataDone(pTInfo, bResult);
return true;
}