open
system\core\init\property_service.c
android:
fd = open("/dev/__properties__", O_RDWR | O_CREAT, 0600);
mingw:
fd = open("c:\\__properties__", O_RDWR | O_CREAT, 0600);
if (fd < 0){
fd = creat("c:\\__properties__", O_RDWR | O_CREAT);
if (fd < 0){
printf("ERROR opening.\n\terror is:%s\n", strerror(errno));
return -1;
}
chmod("c:\\__properties__", 0600);
}
ftruncate
mingw
c:\mingw-4.6.1\include\unistd.h
__CRT_INLINE int ftruncate(int __fd, off_t __length)
{
return _chsize (__fd, __length);
}
mmap
system\core\init\property_service.c
android:
data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
mingw:
nt-base.h:
#if !defined(mmap)
# define mmap(address,length,protection,access,file,offset) \
NTMapMemory(address,length,protection,access,file,offset)
#endif
nt-base.c:
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ N T M a p M e m o r y %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Mmap() emulates the Unix method of the same name.
%
% The format of the NTMapMemory method is:
%
% MagickExport void *NTMapMemory(char *address,size_t length,int protection,
% int access,int file,MagickOffsetType offset)
%
*/
//MagickExport void *NTMapMemory(char *address,size_t length,int protection,
void *NTMapMemory(char *address,size_t length,int protection,
int flags,int file,MagickOffsetType offset)
{
DWORD
access_mode,
high_length,
high_offset,
low_length,
low_offset,
protection_mode;
HANDLE
file_handle,
map_handle;
void
*map;
(void) address;
access_mode=0;
file_handle=INVALID_HANDLE_VALUE;
low_length=(DWORD) (length & 0xFFFFFFFFUL);
//The high-order DWORD of the maximum size of the file mapping object. normally it should be 0, unless
//the file size is extremely big.
//refer to MemoryMappedFile::map in https://raw.github.com/zimbatm/deb-mongodb/master/util/mmap_win.cpp
// high_length=(DWORD) ((((MagickOffsetType) length) >> 32) & 0xFFFFFFFFUL);
high_length=0;
map_handle=INVALID_HANDLE_VALUE;
map=(void *) NULL;
low_offset=(DWORD) (offset & 0xFFFFFFFFUL);
high_offset=(DWORD) ((offset >> 32) & 0xFFFFFFFFUL);
protection_mode=0;
if (protection & PROT_WRITE)
{
access_mode=FILE_MAP_WRITE;
if (!(flags & MAP_PRIVATE))
protection_mode=PAGE_READWRITE;
else
{
access_mode=FILE_MAP_COPY;
protection_mode=PAGE_WRITECOPY;
}
}
else
if (protection & PROT_READ)
{
access_mode=FILE_MAP_READ;
protection_mode=PAGE_READONLY;
}
if ((file == -1) && (flags & MAP_ANONYMOUS))
file_handle=INVALID_HANDLE_VALUE;
else
file_handle=(HANDLE) _get_osfhandle(file);
map_handle=CreateFileMapping(file_handle,0,protection_mode,high_length,
low_length,0);
if (map_handle)
{
map=(void *) MapViewOfFile(map_handle,access_mode,high_offset,low_offset,
length);
CloseHandle(map_handle);
}
if (map == (void *) NULL){
printf("ERROR CreateFileMapping.\n\terror is:%s\n", strerror(errno));
return((void *) MAP_FAILED);
}
return((void *) ((char *) map));
} //void *NTMapMemory(char *address,size_t length,int protection,
引入 在IOS应用中经常要在程序中显示应用更新状态,可能是通过程序本身,也可能是服务推送,那么怎样在应用icon及UITabBar又上角带红圈中数字呢,下面将简单说明。 实现 //ICON [[UIApplication sharedApplication] setApplicationIconBadgeNumber:number]; //number为显示在ICON上的整数 //UITabBar [tabBarItem setBadgeValue:[NSString stringWithFormat:@"%d",number]]; //tabBarItem获取方法:[[[tabBarCtr tabBar] items] objectAtIndex:i];【tabBarCtr为APPDelegate中的UITabBarController,i表示第i个TabBar】 // number为显示在TabBar上的整数
[UIApplication sharedApplication].applicationIconBadgeNumber
1.1 安装maven
从官网 http://maven.apache.org/download.html 下载最新的maven包,解压后放到某个目录。
(linux:/usr/local/apache-maven-3.0.4;windows:c:\apache-maven-3.0.4);
1.2 安装android sdk
linux:/Users/guanjianjun/android-sdks
Windows:c:\program files\android\android-sdk
1.3 安装jdk
1.4 设置环境变量
Linux:
export M2_HOME=/usr/local/apache-maven-3.0.4
export M2=$M2_HOME/bin
export MAVEN_OPTS="-Xms256m -Xmx512m"
export ANDROID_HOME=/Users/guanjianjun/android-sdks
export PATH=$M2:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
Windows:
在‘我的电脑’->‘属性’-> ‘高级系统设置’ -> ‘高级’-> ‘环境变量下’添加如下环境变量。
ANDROID_HOME=C:\Program Files\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07
CLASSPATH=%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
M2_HOME=C:\apache-maven-3.0.4
M2=%M2_HOME%\bin
MAVEN_OPTS=” -Xms256m -Xmx512m”
PATH后面加上
%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%M2%
1.5 更改i-jetty-3.1的pom.xml文件
怎么修改请见svn里文件的注释,这里仅列出修改过的地方
svn: https://portal.src.corp.qihoo.net/svn/WirelessBrowser/Cloud_acceleration/investigation/i-jetty-3.1
=============Pom.xml===========
<android.version>4.1.1.4</android.version>
<android.sdk.version>7</android.sdk.version>
=============i-jetty-ui/pom.xml===========
<artifactId>android-maven-plugin</artifactId>
<version>3.4.0</version>
>mvn clean install
**不出意外的话就能生成apk了。
1 Install the ADT, Android SDK, m2eclipse, Maven, JDK, 及配置环境变量
2 i-jetty下载及导入Eclipse
源码地址:http://code.google.com/p/i-jetty/downloads/list
3 使用Import->Maven->Existing Maven Projects来导入i-jetty的Maven项目
Eclipse下编译Maven项目ijetty-parent
Run as -> maven clean -> maven install 即可。