Skip to content

Commit

Permalink
No more override of posix functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Jan 2, 2016
1 parent 87e0db8 commit 77b52ba
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 1,844 deletions.
4 changes: 0 additions & 4 deletions src/main/java/com/frostwire/jlibtorrent/swig/libtorrent.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,4 @@ public static String boost_lib_version() {
return libtorrent_jni.boost_lib_version();
}

public static void set_global_posix_file_functions(swig_posix_file_functions fns) {
libtorrent_jni.set_global_posix_file_functions(swig_posix_file_functions.getCPtr(fns), fns);
}

}
42 changes: 0 additions & 42 deletions src/main/java/com/frostwire/jlibtorrent/swig/libtorrent_jni.java
Original file line number Diff line number Diff line change
Expand Up @@ -3342,33 +3342,6 @@ public class libtorrent_jni {
public final static native long new_swig_peer_plugin();
public final static native void swig_peer_plugin_director_connect(swig_peer_plugin obj, long cptr, boolean mem_own, boolean weak_global);
public final static native void swig_peer_plugin_change_ownership(swig_peer_plugin obj, long cptr, boolean take_or_release);
public final static native void swig_posix_stat_mode_set(long jarg1, swig_posix_stat jarg1_, int jarg2);
public final static native int swig_posix_stat_mode_get(long jarg1, swig_posix_stat jarg1_);
public final static native void swig_posix_stat_size_set(long jarg1, swig_posix_stat jarg1_, int jarg2);
public final static native int swig_posix_stat_size_get(long jarg1, swig_posix_stat jarg1_);
public final static native void swig_posix_stat_atime_set(long jarg1, swig_posix_stat jarg1_, int jarg2);
public final static native int swig_posix_stat_atime_get(long jarg1, swig_posix_stat jarg1_);
public final static native void swig_posix_stat_mtime_set(long jarg1, swig_posix_stat jarg1_, int jarg2);
public final static native int swig_posix_stat_mtime_get(long jarg1, swig_posix_stat jarg1_);
public final static native void swig_posix_stat_ctime_set(long jarg1, swig_posix_stat jarg1_, int jarg2);
public final static native int swig_posix_stat_ctime_get(long jarg1, swig_posix_stat jarg1_);
public final static native long new_swig_posix_stat();
public final static native void delete_swig_posix_stat(long jarg1);
public final static native void delete_swig_posix_file_functions(long jarg1);
public final static native int swig_posix_file_functions_open(long jarg1, swig_posix_file_functions jarg1_, String jarg2, int jarg3, int jarg4);
public final static native int swig_posix_file_functions_openSwigExplicitswig_posix_file_functions(long jarg1, swig_posix_file_functions jarg1_, String jarg2, int jarg3, int jarg4);
public final static native int swig_posix_file_functions_mkdir(long jarg1, swig_posix_file_functions jarg1_, String jarg2, int jarg3);
public final static native int swig_posix_file_functions_mkdirSwigExplicitswig_posix_file_functions(long jarg1, swig_posix_file_functions jarg1_, String jarg2, int jarg3);
public final static native int swig_posix_file_functions_rename(long jarg1, swig_posix_file_functions jarg1_, String jarg2, String jarg3);
public final static native int swig_posix_file_functions_renameSwigExplicitswig_posix_file_functions(long jarg1, swig_posix_file_functions jarg1_, String jarg2, String jarg3);
public final static native int swig_posix_file_functions_remove(long jarg1, swig_posix_file_functions jarg1_, String jarg2);
public final static native int swig_posix_file_functions_removeSwigExplicitswig_posix_file_functions(long jarg1, swig_posix_file_functions jarg1_, String jarg2);
public final static native int swig_posix_file_functions_stat(long jarg1, swig_posix_file_functions jarg1_, String jarg2, long jarg3, swig_posix_stat jarg3_);
public final static native int swig_posix_file_functions_statSwigExplicitswig_posix_file_functions(long jarg1, swig_posix_file_functions jarg1_, String jarg2, long jarg3, swig_posix_stat jarg3_);
public final static native long new_swig_posix_file_functions();
public final static native void swig_posix_file_functions_director_connect(swig_posix_file_functions obj, long cptr, boolean mem_own, boolean weak_global);
public final static native void swig_posix_file_functions_change_ownership(swig_posix_file_functions obj, long cptr, boolean take_or_release);
public final static native void set_global_posix_file_functions(long jarg1, swig_posix_file_functions jarg1_);
public final static native long torrent_alert_SWIGUpcast(long jarg1);
public final static native long peer_alert_SWIGUpcast(long jarg1);
public final static native long tracker_alert_SWIGUpcast(long jarg1);
Expand Down Expand Up @@ -3652,21 +3625,6 @@ public static void SwigDirector_swig_peer_plugin_tick(swig_peer_plugin jself) {
public static boolean SwigDirector_swig_peer_plugin_write_request(swig_peer_plugin jself, long r) {
return jself.write_request(new peer_request(r, false));
}
public static int SwigDirector_swig_posix_file_functions_open(swig_posix_file_functions jself, String pathname, int flags, int mode) {
return jself.open(pathname, flags, mode);
}
public static int SwigDirector_swig_posix_file_functions_mkdir(swig_posix_file_functions jself, String pathname, int mode) {
return jself.mkdir(pathname, mode);
}
public static int SwigDirector_swig_posix_file_functions_rename(swig_posix_file_functions jself, String oldpath, String newpath) {
return jself.rename(oldpath, newpath);
}
public static int SwigDirector_swig_posix_file_functions_remove(swig_posix_file_functions jself, String pathname) {
return jself.remove(pathname);
}
public static int SwigDirector_swig_posix_file_functions_stat(swig_posix_file_functions jself, String path, long buf) {
return jself.stat(path, (buf == 0) ? null : new swig_posix_stat(buf, false));
}

private final static native void swig_module_init();
static {
Expand Down

This file was deleted.

82 changes: 0 additions & 82 deletions src/main/java/com/frostwire/jlibtorrent/swig/swig_posix_stat.java

This file was deleted.

161 changes: 0 additions & 161 deletions swig/libtorrent.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,167 +402,6 @@ swig_peer_plugin* swig_torrent_plugin::new_peer_connection(libtorrent::peer_conn
return NULL;
}

// handling system call wraps

extern "C" {

int posix_open(const char* pathname, int flags, ...);
int posix_mkdir(const char* pathname, mode_t mode);
int posix_rename(const char *oldpath, const char *newpath);
int posix_remove(const char *pathname);
int posix_lstat(const char* path, struct ::stat* buf);
int posix_stat(const char* path, struct ::stat* buf);

} // extern "C"

struct swig_posix_stat {
int mode;
long size;
long atime;
long mtime;
long ctime;
};

class swig_posix_file_functions {
public:
virtual ~swig_posix_file_functions() {
}

virtual int open(const char* pathname, int flags, int mode) {
#ifndef _WIN32
return ::open(pathname, flags, mode);
#else
return -1;
#endif
}

virtual int mkdir(const char* pathname, int mode) {
#ifndef _WIN32
return ::mkdir(pathname, mode);
#else
return -1;
#endif
}

virtual int rename(const char *oldpath, const char *newpath) {
#ifndef _WIN32
return ::rename(oldpath, newpath);
#else
return -1;
#endif
}

virtual int remove(const char *pathname) {
#ifndef _WIN32
return ::remove(pathname);
#else
return -1;
#endif
}

virtual int stat(const char* path, swig_posix_stat* buf) {
#ifndef _WIN32
struct ::stat ret;
int r = ::stat(path, &ret);
buf->mode = ret.st_mode;
buf->size = ret.st_size;
buf->atime = ret.st_atime;
buf->mtime = ret.st_mtime;
buf->ctime = ret.st_ctime;
return r;
#else
return -1;
#endif
}
};

swig_posix_file_functions* g_posix_file_functions = NULL;

void set_global_posix_file_functions(swig_posix_file_functions* fns) {
g_posix_file_functions = fns;
}

extern "C" {

int posix_open(const char* pathname, int flags, ...) {
#ifndef _WIN32
int mode = 0;
if (flags & O_CREAT) {
va_list arg;
va_start(arg, flags);
mode = va_arg(arg, int);
va_end(arg);
}
return g_posix_file_functions != NULL ? g_posix_file_functions->open(pathname, flags, mode) : ::open(pathname, flags, mode);
#else
return -1;
#endif
}

int posix_mkdir(const char* pathname, mode_t mode) {
#ifndef _WIN32
return g_posix_file_functions != NULL ? g_posix_file_functions->mkdir(pathname, mode) : ::mkdir(pathname, mode);
#else
return -1;
#endif
}

int posix_rename(const char *oldpath, const char *newpath) {
#ifndef _WIN32
return g_posix_file_functions != NULL ? g_posix_file_functions->rename(oldpath, newpath) : ::rename(oldpath, newpath);
#else
return -1;
#endif
}

int posix_remove(const char *pathname) {
#ifndef _WIN32
return g_posix_file_functions != NULL ? g_posix_file_functions->remove(pathname) : ::remove(pathname);
#else
return -1;
#endif
}

int posix_lstat(const char* path, struct ::stat* buf) {
#ifndef _WIN32
if (g_posix_file_functions != NULL) {
swig_posix_stat ret;
int r = g_posix_file_functions->stat(path, &ret);
buf->st_mode = ret.mode;
buf->st_size = ret.size;
buf->st_atime = ret.atime;
buf->st_mtime = ret.mtime;
buf->st_ctime = ret.ctime;
return r;
} else {
return ::lstat(path, buf);
}
#else
return -1;
#endif
}

int posix_stat(const char* path, struct ::stat* buf) {
#ifndef _WIN32
if (g_posix_file_functions != NULL) {
swig_posix_stat ret;
int r = g_posix_file_functions->stat(path, &ret);
buf->st_mode = ret.mode;
buf->st_size = ret.size;
buf->st_atime = ret.atime;
buf->st_mtime = ret.mtime;
buf->st_ctime = ret.ctime;
return r;
} else {
return ::stat(path, buf);
}
#else
return -1;
#endif
}

} // extern "C"

#ifdef LIBTORRENT_SWIG_NODE

#include <node.h>
Expand Down

0 comments on commit 77b52ba

Please sign in to comment.