diff options
author | Daniel Brahneborg <basic@chello.se> | 2002-03-08 19:42:40 +0000 |
---|---|---|
committer | Daniel Brahneborg <basic@chello.se> | 2002-03-08 19:42:40 +0000 |
commit | 0f623548115340cf5f2d39abf9098bf27b822b68 (patch) | |
tree | 0573142130e1b73fef1a89855a3712eff1a3b78d /lib/rfsv16.cc | |
parent | 49f6d0f0ca26c10f3e2aa42ef491d9a60bd1a9fc (diff) | |
download | plptools-0f623548115340cf5f2d39abf9098bf27b822b68.tar.gz plptools-0f623548115340cf5f2d39abf9098bf27b822b68.tar.bz2 plptools-0f623548115340cf5f2d39abf9098bf27b822b68.zip |
Added copyFromPsion() that takes a 'to' argument that is a file
descriptor, to be able to use mkstemp().
Diffstat (limited to 'lib/rfsv16.cc')
-rw-r--r-- | lib/rfsv16.cc | 27 |
1 files changed, 27 insertions, 0 deletions
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; |