sqlite移植for symbian

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 05:47 点击:
直接去sqlite网站上档一个源码,然后把文件读写的接口改成symbian的。就可以用了。。
 
 
 
但是需要注意的是,别做成dll,只能做成static lib. dll里面不支持static,如果你非要做成dll,那需要把所有的static放到tls里面。我尝试过,逻辑比较多。而且改动较大。所以static lib就可以了。。
 
 
============================================================================
 
Name : sqlite_symbian.cpp
 
Author :
 
Version : 1.0
 
Copyright : Arthur Hu
 
Description : sqlite_symbian declaration
 
============================================================================
 
*/
 
 
 
#include "sqlite3.h"
 
#include "sqliteInt.h"
 
#include "os_common.h"
 
 
 
#include <f32file.h>
 
#include <stdio.h>
 
#include <string.h>
 
#include <bautils.h>
 
 
 
#include <utf.h>
 
 
 
void Utf8ToUnicode(const char* src, TDes& aDes)
 
{
 
const TUint8* ptr = (const TUint8*) src;
 
TPtrC8 srcPtr(ptr, User::StringLength(ptr));
 
CnvUtfConverter::ConvertToUnicodeFromUtf8(aDes, srcPtr);
 
}
 
 
 
typedef struct SymbianFile SymbianFile;
 
struct SymbianFile
 
{
 
const sqlite3_io_methods *pMethod; /*** Must be first ***/
 
sqlite3_vfs *pVfs; /* The VFS used to open this file */
 
 
 
RFs iFs;
 
RFile iFile;
 
 
 
unsigned char locktype; /* Type of lock currently held on this file */
 
short sharedLockByte; /* Randomly chosen byte used as a shared lock */
 
char zPath[255]; /* Full pathname of this file */
 
};
 
 
 
int FileClose(sqlite3_file* f)
 
{
 
SymbianFile* file = (SymbianFile*) f;
 
file->iFile.Close();
 
file->iFs.Close();
 
return SQLITE_OK;
 
}
 
int FileRead(sqlite3_file* f, void* data, int len, sqlite3_int64 offset)
 
{
 
SymbianFile* file = (SymbianFile*) f;
 
TInt off = offset;
 
TInt err = file->iFile.Seek(ESeekStart, off);
 
 
 
if (err != KErrNone)
 
{
 
return SQLITE_IOERR_READ;
 
}
 
 
 
TPtr8 ptr((TUint8*) data, len);
 
err = file->iFile.Read(ptr);
 
if (err != KErrNone)
 
{
 
return SQLITE_IOERR_READ;
 
}
 
 
 
if (ptr.Length() < len)
 
{
 
return SQLITE_IOERR_SHORT_READ;
 
}
 
 
 
return SQLITE_OK;
 
}
 
 
 
int FileWrite(sqlite3_file* f, const void* data, int len, sqlite3_int64 offset)
 
{
 
SymbianFile* file = (SymbianFile*) f;
 
TInt off = offset;
 
TInt err = file->iFile.Seek(ESeekStart, off);
 
 
 
if (err != KErrNone)
 
{
 
return SQLITE_IOERR_WRITE;
 
}
 
 
 
TPtrC8 ptr((const TUint8*) data, len);
 
err = file->iFile.Write(ptr);
 
if (err != KErrNone)
 

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • cocos2d-x学习笔记(19)--label 、label atlas
      • cocos2d-x学习笔记(23)--地图的使用3--CCTMXLayer
      • Cocos2d-x学习(一):HelloWorld
      • cocos2dx在xcode下开发,编译到android上(2)
      • cocos2d 设置屏幕默认方向
      • cocos2d-x学习笔记(22)--地图的使用2(TMX) --Z-Order、AnchorPoi
      • Cocos2d-x 2.0 之 Actions “三板斧” 之一
      • cocos2d-x学习笔记(18)--游戏打包(windows平台)
      • cocos2d-x学习笔记(16)--spritesheet(精灵表单)
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1