aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/rfsv.h5
-rw-r--r--lib/rfsv16.cc27
-rw-r--r--lib/rfsv16.h1
-rw-r--r--lib/rfsv32.cc24
-rw-r--r--lib/rfsv32.h1
5 files changed, 58 insertions, 0 deletions
diff --git a/lib/rfsv.h b/lib/rfsv.h
index 58c82cb..2a445ef 100644
--- a/lib/rfsv.h
+++ b/lib/rfsv.h
@@ -413,6 +413,11 @@ public:
virtual Enum<errs> copyFromPsion(const char *from, const char *to, void *, cpCallback_t func) = 0;
/**
+ * Copies a file from the Psion to the local machine.
+ */
+ virtual Enum<rfsv::errs> copyFromPsion(const char *from, int fd, cpCallback_t cb) = 0;
+
+ /**
* Copies a file from local machine to the Psion.
*
* @param from Name of the file on the local machine to be copied.
diff --git a/lib/rfsv16.cc b/lib/rfsv16.cc
index 15bb0aa..e920698 100644
--- a/lib/rfsv16.cc
+++ b/lib/rfsv16.cc
@@ -641,6 +641,33 @@ copyFromPsion(const char *from, const char *to, void *ptr, cpCallback_t cb)
}
Enum<rfsv::errs> rfsv16::
+copyFromPsion(const char *from, int fd, void *ptr, cpCallback_t cb)
+{
+ Enum<rfsv::errs> res;
+ u_int32_t handle;
+ u_int32_t len;
+ u_int32_t total = 0;
+
+ if ((res = fopen(P_FSHARE | P_FSTREAM, from, handle)) != E_PSI_GEN_NONE)
+ return res;
+ do {
+ unsigned char buf[RFSV_SENDLEN];
+ if ((res = fread(handle, buf, sizeof(buf), len)) == E_PSI_GEN_NONE) {
+ if (len > 0)
+ write(fd, buf, len);
+ total += len;
+ if (cb && !cb(ptr, total))
+ res = E_PSI_FILE_CANCEL;
+ }
+ } while (len > 0 && (res == E_PSI_GEN_NONE));
+
+ fclose(handle);
+ if (res == E_PSI_FILE_EOF)
+ res = E_PSI_GEN_NONE;
+ return res;
+}
+
+Enum<rfsv::errs> rfsv16::
copyToPsion(const char *from, const char *to, void *ptr, cpCallback_t cb)
{
u_int32_t handle;
diff --git a/lib/rfsv16.h b/lib/rfsv16.h
index fa32e5e..dad9650 100644
--- a/lib/rfsv16.h
+++ b/lib/rfsv16.h
@@ -60,6 +60,7 @@ public:
Enum<rfsv::errs> fread(const u_int32_t, unsigned char * const, const u_int32_t, u_int32_t &);
Enum<rfsv::errs> fwrite(const u_int32_t, const unsigned char * const, const u_int32_t, u_int32_t &);
Enum<rfsv::errs> copyFromPsion(const char * const, const char * const, void *, cpCallback_t);
+ Enum<rfsv::errs> copyFromPsion(const char *from, int fd, void *ptr, cpCallback_t cb);
Enum<rfsv::errs> copyToPsion(const char * const, const char * const, void *, cpCallback_t);
Enum<rfsv::errs> copyOnPsion(const char *, const char *, void *, cpCallback_t);
Enum<rfsv::errs> fsetsize(const u_int32_t, const u_int32_t);
diff --git a/lib/rfsv32.cc b/lib/rfsv32.cc
index 739844e..da9c6e0 100644
--- a/lib/rfsv32.cc
+++ b/lib/rfsv32.cc
@@ -507,6 +507,30 @@ copyFromPsion(const char *from, const char *to, void *ptr, cpCallback_t cb)
}
Enum<rfsv::errs> rfsv32::
+copyFromPsion(const char *from, int fd, cpCallback_t cb)
+{
+ Enum<rfsv::errs> res;
+ u_int32_t handle;
+ u_int32_t len;
+ u_int32_t total = 0;
+
+ if ((res = fopen(EPOC_OMODE_SHARE_READERS | EPOC_OMODE_BINARY, from, handle)) != E_PSI_GEN_NONE)
+ return res;
+ unsigned char *buff = new unsigned char[RFSV_SENDLEN];
+ do {
+ if ((res = fread(handle, buff, RFSV_SENDLEN, len)) == E_PSI_GEN_NONE) {
+ write(fd, buff, len);
+ total += len;
+ if (cb && !cb(NULL, total))
+ res = E_PSI_FILE_CANCEL;
+ }
+ } while ((len > 0) && (res == E_PSI_GEN_NONE));
+ delete [] buff;
+ fclose(handle);
+ return res;
+}
+
+Enum<rfsv::errs> rfsv32::
copyToPsion(const char *from, const char *to, void *ptr, cpCallback_t cb)
{
u_int32_t handle;
diff --git a/lib/rfsv32.h b/lib/rfsv32.h
index 0680354..2adf4d8 100644
--- a/lib/rfsv32.h
+++ b/lib/rfsv32.h
@@ -48,6 +48,7 @@ public:
Enum<rfsv::errs> dir(const char * const, PlpDir &);
Enum<rfsv::errs> dircount(const char * const, u_int32_t &);
Enum<rfsv::errs> copyFromPsion(const char * const, const char * const, void *, cpCallback_t);
+ Enum<rfsv::errs> copyFromPsion(const char *from, int fd, cpCallback_t cb);
Enum<rfsv::errs> copyToPsion(const char * const, const char * const, void *, cpCallback_t);
Enum<rfsv::errs> copyOnPsion(const char * const, const char * const, void *, cpCallback_t);
Enum<rfsv::errs> mkdir(const char * const);