This page was last modified 14:09, 16 April 2008.
Usando Arquivos nas Plataformas S60 e Maemo
From Forum Nokia Wiki
Original: Using_files_with_S60_and_Maemo_Platforms
Comparação
RFile file; GnomeVFSHandle *handle = NULL;
User::LeaveIfError(file.Open(rfs, aFileName, EFileRead)); vfs_result = gnome_vfs_open(&handle, file_name, GNOME_VFS_OPEN_READ);
HBufC8* buf = HBufC8::NewLC(size); temp_buffer = g_malloc(finfo.size + 1); memset(temp_buffer, 0, finfo.size + 1);
User::LeaveIfError(file.Read(bufPtr)); gnome_vfs_read(handle, temp_buffer, finfo.size, &in_bytes);
CleanupStack::PopAndDestroy(2); // file, rfs gnome_vfs_close(handle);
Comparando as Plataformas S60 e Maemo
Plataforma S60
// ----------------------------------------------------
// CBrCtlSampleAppContainer::ReadFileLC(const TDesC& aFileName)
// ----------------------------------------------------
//
HBufC8* CBrCtlSampleAppContainer::ReadFileLC(const TDesC& aFileName)
{
RFs rfs;
RFile file;
User::LeaveIfError(rfs.Connect());
CleanupClosePushL(rfs);
User::LeaveIfError(file.Open(rfs, aFileName, EFileRead));
CleanupClosePushL(file);
TInt size;
User::LeaveIfError(file.Size(size));
HBufC8* buf = HBufC8::NewLC(size);
TPtr8 bufPtr(buf->Des());
User::LeaveIfError(file.Read(bufPtr));
CleanupStack::Pop(); // buf
CleanupStack::PopAndDestroy(2); // file, rfs
CleanupStack::PushL(buf);
return buf;
}
Plataforma Maemo
/* read file */
gchar* read_file_to_buffer( MainView* main, gchar* file_name )
{
GnomeVFSResult vfs_result;
GnomeVFSHandle *handle = NULL;
GnomeVFSFileSize in_bytes;
GnomeVFSFileInfo finfo;
gchar *temp_buffer = NULL;
/* try to get file info */
vfs_result = gnome_vfs_get_file_info(file_name, &finfo, GNOME_VFS_FILE_INFO_DEFAULT);
if ( vfs_result != GNOME_VFS_OK ) {
interface_error( UTFVIEWER_ERROR_OPEN_FAILED, main );
return NULL;
}
/* try to create handle to file */
vfs_result = gnome_vfs_open(&handle, file_name, GNOME_VFS_OPEN_READ);
if ( vfs_result != GNOME_VFS_OK ) {
interface_error( UTFVIEWER_ERROR_OPEN_FAILED, main );
return NULL;
}
/* allocate memory for temp_buffer */
temp_buffer = g_malloc(finfo.size + 1);
memset(temp_buffer, 0, finfo.size + 1);
/* read from file to buffer */
gnome_vfs_read(handle, temp_buffer, finfo.size, &in_bytes);
/* close file */
gnome_vfs_close(handle);
return temp_buffer;
}
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Starting with programming | Genom | Symbian Tools & SDKs | 3 | 2007-02-02 08:23 |
| SISX Python for S60 3.x / Symbian 9 | soenderg | Python | 6 | 2006-08-25 19:16 |
| My idea | rulirahm | Series 40 & S60 Platform Feedback | 4 | 2006-03-16 08:10 |
| createImage leaks memory | mariusfahlbusch | Mobile Java General | 20 | 2005-02-07 10:36 |
| abld helloworld出错,真是郁闷阿! | lorjer | Symbian | 3 | 2004-11-12 13:43 |
