×
Namespaces

Variants
Actions
(Difference between revisions)

Using files with S60 and Maemo Platforms

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetaData)
hamishwillee (Talk | contribs)
m (Text replace - "Category:Symbian" to "")
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 +
[[Category:Maemo]][[Category:Symbian C++]][[Category:Files/Data]][[Category:Porting]]
 +
{{Archived|timestamp=20130205210955|user=[[User:Lpvalente|Lpvalente]]}}
 +
 +
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
Line 21: Line 25:
 
|author= [[User:Ebra]]
 
|author= [[User:Ebra]]
 
}}
 
}}
[[Category:Maemo]][[Category:Symbian]][[Category:Symbian C++]][[Category:Files/Data]][[Category:Porting]]
+
 
 
== Comparison ==
 
== Comparison ==
  

Latest revision as of 09:39, 30 May 2013

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


Article Metadata
Article
Created: ebra (19 Nov 2007)
Last edited: hamishwillee (30 May 2013)

[edit] 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

[edit] 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;
}

[edit] 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;
}
This page was last modified on 30 May 2013, at 09:39.
83 page views in the last 30 days.
×