资源简介
搞android开发的童鞋都知道,有时需要上传文件到SD卡中,但是苦于中文的不好对付(利用数据线,开启SD卡除外),这时用ADB PUSH相当方便,但是就是不支持中文(GBK),现在上传一个重写过的ADB工具,可以自动进行转码,以后push中文文件再也不用烦恼了
代码片段和文件信息
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License Version 2.0 (the “License“);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “sysdeps.h“
#include “adb.h“
#include “adb_client.h“
#include “file_sync_service.h“
#ifdef USE_MINGW
#include
#endif
static unsigned total_bytes;
static long long start_time;
static long long NOW()
{
struct timeval tv;
gettimeofday(&tv 0);
return ((long long) tv.tv_usec) +
1000000LL * ((long long) tv.tv_sec);
}
static void BEGIN()
{
total_bytes = 0;
start_time = NOW();
}
static void END()
{
long long t = NOW() - start_time;
if(total_bytes == 0) return;
if (t == 0) /* prevent division by 0 :-) */
t = 1000000;
fprintf(stderr“%lld KB/s (%lld bytes in %lld.%03llds)\n“
((((long long) total_bytes) * 1000000LL) / t) / 1024LL
(long long) total_bytes (t / 1000000LL) (t % 1000000LL) / 1000LL);
}
void sync_quit(int fd)
{
syncmsg msg;
msg.req.id = ID_QUIT;
msg.req.namelen = 0;
writex(fd &msg.req sizeof(msg.req));
}
typedef void (*sync_ls_cb)(unsigned mode unsigned size unsigned time const char *name void *cookie);
int sync_ls(int fd const char *path sync_ls_cb func void *cookie)
{
syncmsg msg;
char buf[257];
int len;
len = strlen(path);
if(len > 1024) goto fail;
msg.req.id = ID_LIST;
msg.req.namelen = htoll(len);
if(writex(fd &msg.req sizeof(msg.req)) ||
writex(fd path len)) {
goto fail;
}
for(;;) {
if(readx(fd &msg.dent sizeof(msg.dent))) break;
if(msg.dent.id == ID_DONE) return 0;
if(msg.dent.id != ID_DENT) break;
len = ltohl(msg.dent.namelen);
if(len > 256) break;
if(readx(fd buf len)) break;
buf[len] = 0;
func(ltohl(msg.dent.mode)
ltohl(msg.dent.size)
ltohl(msg.dent.time)
buf cookie);
}
fail:
adb_close(fd);
return -1;
}
typedef struct syncsendbuf syncsendbuf;
struct syncsendbuf {
unsigned id;
unsigned size;
char data[SYNC_DATA_MAX];
};
static syncsendbuf send_buffer;
int sync_readtime(int fd const char *path unsigned *timestamp)
{
syncmsg msg;
int len = strlen(path);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 589639 2012-10-22 19:59 adb_zh\adb.exe
文件 96256 2012-10-22 11:33 adb_zh\AdbWinApi.dll
文件 60928 2012-10-22 11:33 adb_zh\AdbWinUsbApi.dll
文件 28515 2012-11-12 20:12 adb_zh\file_sync_client.c
目录 0 2013-08-05 15:49 adb_zh
----------- --------- ---------- ----- ----
775338 5
- 上一篇:jpcap资源
- 下一篇:javacc编译原理实习
相关资源
- robocode必备的中文资料教你怎样从零开
- PC与Android设备通过USB建立通信连接
- java1.7版本API中文版最新
- 贝叶斯分类实现垃圾信息分类支持中
- android adb
- android cmd命令行工具
- 《Java 基础入门传智播客出品》_中文
- Head First_深入浅出Servlets&JSP;(中文第
- Head First_深入浅出Java(中文第2版)
- robocode_API中文参考(java).pdf
- java核心技术卷一第十版中文版
- axis2-adb-1.4.1.jar,用于解决MTOMAwarexm<
- solr4的IK中文分词器IKAnalyzer2012FF_u1.j
- servlet文档API中文版
- java实现的中文词性标注算法
- j2ee外文期刊以及相应的中文翻译
- AdbWinApi.dll
- 成功解决 Android 中文文件名
- JAVA混淆工具Allatori-5.9-Demo帮助文档中
- jspSmartUpload完美支持中文_源码和jar包
- 自动生带中文注释的实体类配置文件
- 解决了通过java访问OPC Server中文乱码的
- html转pdf的core-renderer.jar支持中文自动
- osworkflow中文入门指南,osworkflow+hibe
- myeclipse中jsp的preview中文乱码完美解决
- Head-First-Java(中文第二版全部源代码
- Head First Java源代码 (中文第2版) (
- 解决adb传输中文出现乱码的最新版a
- JAVA毕业设计外文翻译 中文+英文JSP技
- javadbf.4.1.jar
评论
共有 条评论