Categories: S60 | Maemo
This page was last modified 13:55, 11 December 2007.
Using files with S60 and Maemo Platforms
From Forum Nokia Wiki
Comparison
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);
Comparing S60 and Maemo Platforms
S60 Platform
// ----------------------------------------------------
// 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;
}
Maemo Platform
/* 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 |
| Location Log Application | znakharenko | Python | 9 | 2006-02-06 20:01 |
| How can i change linux kernel for handheld device (Nokia N800/810) | Farrukhshahzad | General Discussion | 1 | 2007-11-28 18:19 |
| Can I use the same UID for my application on S60 and UIQ? | tote_b5 | General Symbian C++ | 1 | 2007-02-06 14:02 |
| 请教:电话簿打包的问题 | superrookie406 | Symbian | 2 | 2006-08-30 04:23 |
| IMEI for N70 or any S60 Platforms? | AyedSQ | Mobile Java Networking & Messaging & Security | 2 | 2006-10-05 07:16 |
