randomizw

android port

git-svn-id: svn://db.shs.com.ru/pip@39 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-03-23 08:49:21 +00:00
parent f89764d6bc
commit cef64a9b80
10 changed files with 40 additions and 16 deletions

View File

@@ -32,7 +32,7 @@ const PIChar PIDir::separator = '/';
#endif
#ifndef WINDOWS
# ifdef ANDROID
# include <sys/dirent.h>
# include <dirent.h>
# else
# include <sys/dir.h>
# endif
@@ -219,7 +219,7 @@ PIVector<PIFile::FileInfo> PIDir::entries() {
const_cast<char*>(p.data()), 0
# endif
, 0,
# ifdef MAC_OS
# if defined(MAC_OS) || defined(ANDROID)
alphasort);
# else
versionsort);

View File

@@ -454,7 +454,7 @@ bool PIEthernet::listen(bool threaded) {
return true;
}
//#include <QDebug>
int PIEthernet::read(void * read_to, int max_size) {
//cout << "read " << sock << endl;
if (sock == -1) init();
@@ -486,8 +486,10 @@ int PIEthernet::read(void * read_to, int max_size) {
PRIVATE->addr_.sin_len = sizeof(PRIVATE->addr_);
#endif
//piCoutObj << "connect to " << ip_ << ":" << port_ << "...";
connected_ = (::connect(sock, (sockaddr * )&PRIVATE->addr_, sizeof(PRIVATE->addr_)) == 0);
//qDebug() << "connect to " << ip_.data() << ":" << port_ << sock << PRIVATE->addr_.sin_addr.s_addr << "...";
connected_ = (::connect(sock, (sockaddr * )&(PRIVATE->addr_), sizeof(PRIVATE->addr_)) == 0);
//piCoutObj << "connect to " << ip_ << ":" << port_ << connected_;
//qDebug() << "connect to " << ip_.data() << ":" << port_ << connected_;
if (!connected_)
piCoutObj << "Can`t connect to " << ip_ << ":" << port_ << ", " << ethErrorString();
opened_ = connected_;
@@ -497,13 +499,16 @@ int PIEthernet::read(void * read_to, int max_size) {
} else
piMSleep(10);
//piCout << "connected to" << path();
//qDebug() << "connected to" << path().data();
}
if (!connected_) return -1;
errorClear();
rs = ethRecv(sock, read_to, max_size);
//piCoutObj << "readed" << rs;
//qDebug() << "readed" << rs;
if (rs <= 0) {
lerr = ethErrorCore();
//qDebug() << "readed error" << errorString().data();
#ifdef WINDOWS
if (lerr == WSAEWOULDBLOCK || /*lerr == NO_ERROR ||*/ lerr == WSAETIMEDOUT) {
#else
@@ -521,6 +526,7 @@ int PIEthernet::read(void * read_to, int max_size) {
//piCoutObj << "eth" << ip_ << "disconnected";
}
if (rs > 0) received(read_to, rs);
//qDebug() << "return from read" << rs;
return rs;
case UDP:
memset(&PRIVATE->raddr_, 0, sizeof(PRIVATE->raddr_));

View File

@@ -322,15 +322,20 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
ret.size = fs.st_size;
ret.id_user = fs.st_uid;
ret.id_group = fs.st_gid;
#ifdef MAC_OS
# define ATIME st_atimespec
# define MTIME st_ctimespec
#ifdef ANDROID
ret.time_access = PIDateTime::fromSystemTime(PISystemTime(fs.st_atime, fs.st_atime_nsec));
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.st_mtime, fs.st_mtime_nsec));
#else
# define ATIME st_atim
# define MTIME st_mtim
# ifdef MAC_OS
# define ATIME st_atimespec
# define MTIME st_ctimespec
# else
# define ATIME st_atim
# define MTIME st_mtim
# endif
ret.time_access = PIDateTime::fromSystemTime(PISystemTime(fs.ATIME.tv_sec, fs.ATIME.tv_nsec));
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.MTIME.tv_sec, fs.MTIME.tv_nsec));
#endif
ret.time_access = PIDateTime::fromSystemTime(PISystemTime(fs.ATIME.tv_sec, fs.ATIME.tv_nsec));
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.MTIME.tv_sec, fs.MTIME.tv_nsec));
ret.perm_user = FileInfo::Permissions((mode & S_IRUSR) == S_IRUSR, (mode & S_IWUSR) == S_IWUSR, (mode & S_IXUSR) == S_IXUSR);
ret.perm_group = FileInfo::Permissions((mode & S_IRGRP) == S_IRGRP, (mode & S_IWGRP) == S_IWGRP, (mode & S_IXGRP) == S_IXGRP);
ret.perm_other = FileInfo::Permissions((mode & S_IROTH) == S_IROTH, (mode & S_IWOTH) == S_IWOTH, (mode & S_IXOTH) == S_IXOTH);