Added support for android SetFileTime.

Deactivated libjpeg support for android.
This commit is contained in:
Armin Novak 2016-02-26 12:13:02 +01:00
parent 5537230298
commit 98d4a9347a
3 changed files with 33 additions and 4 deletions

View File

@ -80,6 +80,7 @@ fi
common_run mkdir -p $BUILD_SRC common_run mkdir -p $BUILD_SRC
CMAKE_CMD_ARGS="-DANDROID_NDK=$ANDROID_NDK \ CMAKE_CMD_ARGS="-DANDROID_NDK=$ANDROID_NDK \
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
-DCMAKE_TOOLCHAIN_FILE=$SRC_DIR/cmake/AndroidToolchain.cmake \ -DCMAKE_TOOLCHAIN_FILE=$SRC_DIR/cmake/AndroidToolchain.cmake \
-DCMAKE_INSTALL_PREFIX=$BUILD_DST \ -DCMAKE_INSTALL_PREFIX=$BUILD_DST \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \

View File

@ -4,10 +4,11 @@
SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}") SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}")
SCRIPT_PATH=$(realpath "$SCRIPT_PATH") SCRIPT_PATH=$(realpath "$SCRIPT_PATH")
WITH_JPEG=1 WITH_JPEG=0
WITH_OPENH264=1 WITH_OPENH264=1
WITH_OPENSSL=1 WITH_OPENSSL=1
BUILD_DEPS=1 BUILD_DEPS=1
ANDROID_NATIVE_API_LEVEL=android-12
JPEG_TAG=master JPEG_TAG=master
OPENH264_TAG=v1.5.0 OPENH264_TAG=v1.5.0

View File

@ -352,22 +352,25 @@ static BOOL FileSetFileTime(HANDLE hFile, const FILETIME *lpCreationTime,
const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime) const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime)
{ {
int rc; int rc;
#ifdef __APPLE__ #if defined(__APPLE__) || defined(ANDROID)
struct stat buf; struct stat buf;
#endif #endif
#ifdef ANDROID
struct timeval timevals[2];
#else
struct timespec times[2]; /* last access, last modification */ struct timespec times[2]; /* last access, last modification */
#endif
WINPR_FILE* pFile = (WINPR_FILE*)hFile; WINPR_FILE* pFile = (WINPR_FILE*)hFile;
const UINT64 EPOCH_DIFF = 11644473600ULL; const UINT64 EPOCH_DIFF = 11644473600ULL;
if (!hFile) if (!hFile)
return FALSE; return FALSE;
#ifdef __APPLE__ #if defined(__APPLE__) || defined(ANDROID)
rc = fstat(fileno(pFile->fp), &buf); rc = fstat(fileno(pFile->fp), &buf);
if (rc < 0) if (rc < 0)
return FALSE; return FALSE;
#endif #endif
memset(times, 0, sizeof(times));
if (!lpLastAccessTime) if (!lpLastAccessTime)
{ {
#ifdef __APPLE__ #ifdef __APPLE__
@ -377,7 +380,11 @@ static BOOL FileSetFileTime(HANDLE hFile, const FILETIME *lpCreationTime,
times[0].tv_sec = buf.st_atime; times[0].tv_sec = buf.st_atime;
times[0].tv_nsec = buf.st_atimensec; times[0].tv_nsec = buf.st_atimensec;
#endif #endif
#elif ANDROID
timevals[0].tv_sec = buf.st_mtime;
timevals[0].tv_usec = buf.st_mtimensec / 1000UL;
#else #else
times[0].tv_sec = UTIME_OMIT;
times[0].tv_nsec = UTIME_OMIT; times[0].tv_nsec = UTIME_OMIT;
#endif #endif
} }
@ -388,8 +395,15 @@ static BOOL FileSetFileTime(HANDLE hFile, const FILETIME *lpCreationTime,
tmp -= EPOCH_DIFF; tmp -= EPOCH_DIFF;
tmp /= 10ULL; tmp /= 10ULL;
#ifdef ANDROID
tmp /= 10000ULL;
timevals[0].tv_sec = tmp / 10000ULL;
timevals[0].tv_usec = tmp % 10000ULL;
#else
times[0].tv_sec = tmp / 10000000ULL; times[0].tv_sec = tmp / 10000000ULL;
times[0].tv_nsec = tmp % 10000000ULL; times[0].tv_nsec = tmp % 10000000ULL;
#endif
} }
if (!lpLastWriteTime) if (!lpLastWriteTime)
{ {
@ -400,7 +414,11 @@ static BOOL FileSetFileTime(HANDLE hFile, const FILETIME *lpCreationTime,
times[1].tv_sec = buf.st_mtime; times[1].tv_sec = buf.st_mtime;
times[1].tv_nsec = buf.st_mtimensec; times[1].tv_nsec = buf.st_mtimensec;
#endif #endif
#elif ANDROID
timevals[1].tv_sec = buf.st_mtime;
timevals[1].tv_usec = buf.st_mtimensec / 1000UL;
#else #else
times[1].tv_sec = UTIME_OMIT;
times[1].tv_nsec = UTIME_OMIT; times[1].tv_nsec = UTIME_OMIT;
#endif #endif
} }
@ -411,13 +429,22 @@ static BOOL FileSetFileTime(HANDLE hFile, const FILETIME *lpCreationTime,
tmp -= EPOCH_DIFF; tmp -= EPOCH_DIFF;
tmp /= 10ULL; tmp /= 10ULL;
#ifdef ANDROID
tmp /= 10000ULL;
timevals[1].tv_sec = tmp / 10000ULL;
timevals[1].tv_usec = tmp % 10000ULL;
#else
times[1].tv_sec = tmp / 10000000ULL; times[1].tv_sec = tmp / 10000000ULL;
times[1].tv_nsec = tmp % 10000000ULL; times[1].tv_nsec = tmp % 10000000ULL;
#endif
} }
// TODO: Creation time can not be handled! // TODO: Creation time can not be handled!
#ifdef __APPLE__ #ifdef __APPLE__
rc = futimes(fileno(pFile->fp), times); rc = futimes(fileno(pFile->fp), times);
#elif ANDROID
rc = utimes(pFile->lpFileName, timevals);
#else #else
rc = futimens(fileno(pFile->fp), times); rc = futimens(fileno(pFile->fp), times);
#endif #endif