string -> char
string.c_str()
char -> string
string(char*)
拼接字符串
char* a=new char[strlen(char1)+strlen(char2)……]
sprintf(a,”formatter”,char1,char2,…..)
string aw=string(char1)+string(char2)
创建 assets1
2
3
4
5
6
7
8
9
10
11
12this->pEnv=env;
jclass class_activity = env->GetObjectClass (activity);
jmethodID method_resource = getMethodIdOrThrow (
env, class_activity, "getResources", "()Landroid/content/res/Resources;");
jobject obj_resource = env->CallObjectMethod (activity, method_resource);
jclass class_resource = env->GetObjectClass (obj_resource);
jmethodID method_assets = getMethodIdOrThrow (
env, class_resource, "getAssets", "()Landroid/content/res/AssetManager;");
jobject obj_asset = env->CallObjectMethod (obj_resource, method_assets);
this->am = AAssetManager_fromJava (env, obj_asset);
释放文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26if(0!=access(dst,F_OK))
{
LOGD("need create %s",dst);
ofstream m_file_o;
m_file_o.open(dst,ios::binary|ios::out);
if(m_file_o)
{
char *buffer=(char*)malloc(_BUFFER_SIZE+1);
buffer[_BUFFER_SIZE+1]=0;
int count=-1;
AAsset* asset=this->open(src);
if(NULL!=asset){
while((count=AAsset_read(asset,buffer,_BUFFER_SIZE))>0)
{
m_file_o.write(buffer,count);
}
}
m_file_o.close();
AAsset_close(asset);
delete buffer;
}
}else{
LOGD("%s has exist",dst);
}
return JNI_TRUE;
目录遍历
http://songlee24.github.io/2014/09/20/linux-get-directory/
DT_UNKNOWN,未知的类型
DT_REG,普通文件
DT_DIR,普通目录
DT_FIFO,命名管道或FIFO
DT_SOCK,本地套接口
DT_CHR,字符设备文件
DT_BLK,块设备文件