35#include "ignore-value.h"
51 a.addString(n.c_str());
57 handle =
a.getDWord(0);
70 handle =
a.getDWord(0);
71 tmpname =
a.getString(6);
81 a.addString(n.c_str());
87 handle =
a.getDWord(0);
97 a.addString(n.c_str());
103 handle =
a.getDWord(0);
113 a.addString(n.c_str());
118 if (!res &&
a.getLen() == 4) {
119 handle =
a.getDWord(0);
170 for (
int i = 0; i < longLen; i++, d++) {
220 a.addString(n.c_str());
238 a.addString(n.c_str());
249 a.addString(n.c_str());
265 a.addString(n.c_str());
266 const char *p = strrchr(n.c_str(),
'\\');
283 e.
size =
a.getDWord(8);
284 e.
UID =
PlpUID(
a.getDWord(20),
a.getDWord(24),
a.getDWord(28));
297 a.addString(n.c_str());
322 while (
a.getLen() > 16) {
323 int d = 36 +
a.getDWord(32);
331 a.discardFirstBytes(d);
352 for (
int i = 25; i >= 0; i--) {
354 if (
a.getByte(i) != 0) {
366 a.addDWord(toupper(drive) -
'A');
375 dinfo.
setSize(
a.getDWord(20),
a.getDWord(24));
376 dinfo.
setSpace(
a.getDWord(28),
a.getDWord(32));
378 dinfo.
setName(toupper(drive),
a.getString(40));
400 result =
socket_->sendBufferStore(
a);
403 result =
socket_->sendBufferStore(
a);
412 if (
socket_->getBufferStore(data) == 1 &&
428 unsigned char *p = buf;
439 if ((l =
a.getLen()) > 0) {
440 memcpy(p,
a.getString(), l);
445 }
while ((count < len) && (l > 0));
450 const unsigned char *
const buf,
454 const unsigned char *p = buf;
474 }
while ((count < len) && (l > 0));
495 op.write((
char *)buff, len);
497 if (cb && !cb(ptr, total)) {
521 ignore_value(write(fd, buff, len));
523 if (cb && !cb(NULL, total)) {
555 if (cb && !cb(ptr, total)) {
567 uint32_t handle_from;
606 if (cb && !cb(ptr, total)) {
625 a.addString(n.c_str());
651 uint32_t calcpos = 0;
683 savpos =
a.getDWord(0);
701 savpos =
a.getDWord(0);
709 a.addDWord(savpos + mypos);
729 realpos =
a.getDWord(0);
735 calcpos = savpos + mypos;
742 if (calcpos > realpos) {
762 realpos =
a.getDWord(0);
771 if (n.find_last_of(
'\\') != (n.size() - 1)) {
775 a.addString(n.c_str());
785 if (n.find_last_of(
'\\') != (n.size() - 1)) {
789 a.addString(n.c_str());
800 a.addWord(on.size());
801 a.addString(on.c_str());
802 a.addWord(nn.size());
803 a.addString(nn.c_str());
814 a.addString(n.c_str());
823 a.addDWord(toupper(drive) -
'A');
824 a.addWord(strlen(name));
881 cerr <<
"FATAL: invalid error-code" << endl;
882 cerr <<
"status: " << istatus <<
" " << hex << istatus << endl;
A generic container for an array of bytes.
uint16_t getWord(long pos=0) const
Retrieves the word at index pos.
uint32_t getDWord(long pos=0) const
Retrieves the dword at index pos.
void addDWord(long dw)
Appends a dword to the content of this instance.
unsigned long getLen() const
Retrieves the length of a BufferStore.
unsigned char getByte(long pos=0) const
Retrieves the byte at index pos.
void discardFirstBytes(int len=0)
Removes bytes from the start of the buffer.
void init()
Initializes the BufferStore.
A class representing information about a Disk drive on the psion.
void setSpace(uint32_t spaceLo, uint32_t spaceHi)
void setName(char drive, const char *const volname)
void setUID(uint32_t uid)
void setMediaType(MediaType type)
void setDriveAttributes(uint32_t driveAttribute)
void setMediaAttributes(uint32_t mediaAttribute)
void setSize(uint32_t sizeLo, uint32_t sizeHi)
Wrapper class featuring range-checking and string representation of enumerated values.
A class, representing a directory entry of the Psion.
A class, representing the UIDs of a file on the Psion.
Psion time related utility class.
uint32_t getPsiTimeHi(void)
Retrieves the instance's current value in Psion time format, low 32 bits.
uint32_t getPsiTimeLo(void)
Retrieves the instance's current value in Psion time format, high 32 bits.
void setPsiTime(psi_timeval *_ptv)
Modifies the value of this instance.
Enum< RFSV::errs > pathtest(const char *const)
Checks to see if the directory component of a path or file name exists and is valid.
Enum< RFSV::errs > getResponse(BufferStore &)
Enum< RFSV::errs > fcreatefile(const uint32_t, const char *const, uint32_t &)
Creates a named file.
Enum< RFSV::errs > mktemp(uint32_t &, std::string &)
Creates a unique temporary file.
Enum< RFSV::errs > devinfo(const char, Drive &)
Retrieves details about a drive.
Enum< RFSV::errs > fseek(const uint32_t, const int32_t, const uint32_t, uint32_t &)
Sets the current file position of a file on the Psion.
Enum< RFSV::errs > devlist(uint32_t &)
Retrieves available drives on the Psion.
Enum< RFSV::errs > fgetattr(const char *const, uint32_t &)
Retrieves attributes of a file on the Psion.
uint32_t attr2std(const uint32_t)
Enum< RFSV::errs > mkdir(const char *const)
Creates a directory on the Psion.
Enum< RFSV::errs > fread(const uint32_t, unsigned char *const, const uint32_t, uint32_t &)
Reads from a file on the Psion.
Enum< RFSV::errs > fwrite(const uint32_t, const unsigned char *const, const uint32_t, uint32_t &)
Write to a file on the Psion.
Enum< RFSV::errs > setVolumeName(const char, const char *const)
Set the name of a Psion Volume (Drive).
uint32_t opMode(const uint32_t)
Converts an open-mode (A combination of the PSI_O_ constants.) from generic representation to the mac...
bool sendCommand(enum commands, BufferStore &)
Enum< RFSV::errs > rmdir(const char *const)
Removes a directory on the Psion.
Enum< RFSV::errs > err2psierr(int32_t)
Enum< RFSV::errs > fopen(const uint32_t, const char *const, uint32_t &)
Opens a file.
Enum< RFSV::errs > closedir(RFSVDirHandle &)
Close a directory, previously opened with opendir.
Enum< RFSV::errs > fclose(const uint32_t)
Close a file on the Psion whih was previously opened/created by using fopen , fcreatefile ,...
Enum< RFSV::errs > fopendir(const uint32_t, const char *, uint32_t &)
Enum< RFSV::errs > fsetsize(uint32_t, uint32_t)
Resizes an open file on the Psion.
Enum< RFSV::errs > remove(const char *const)
Removes a file on the Psion.
Enum< RFSV::errs > opendir(const uint32_t, const char *const, RFSVDirHandle &)
Open a directory for reading with readdir.
Enum< RFSV::errs > fsetmtime(const char *const, PsiTime const)
Sets the modification time of a file on the Psion.
Enum< RFSV::errs > fgeteattr(const char *const, PlpDirent &)
Retrieves attributes, size and modification time of a file on the Psion.
Enum< RFSV::errs > readdir(RFSVDirHandle &, PlpDirent &)
Read directory entries.
Enum< RFSV::errs > freplacefile(const uint32_t, const char *const, uint32_t &)
Creates an named file, overwriting an existing file.
Enum< RFSV::errs > rename(const char *const, const char *const)
Renames a file on the Psion.
Enum< RFSV::errs > copyFromPsion(const char *const, const char *const, void *, cpCallback_t)
Copies a file from the Psion to the local machine.
Enum< RFSV::errs > dircount(const char *const, uint32_t &)
Counts number of entries in a directory.
uint32_t std2attr(const uint32_t)
Enum< RFSV::errs > copyToPsion(const char *const, const char *const, void *, cpCallback_t)
Copies a file from local machine to the Psion.
Enum< RFSV::errs > dir(const char *const, PlpDir &)
Reads a directory on the Psion.
Enum< RFSV::errs > fgetmtime(const char *const, PsiTime &)
Retrieves the modification time of a file on the Psion.
Enum< RFSV::errs > fsetattr(const char *const, const uint32_t, const uint32_t)
RFSV32(std::unique_ptr< TCPSocket > socket)
@ EPOC_OMODE_SHARE_EXCLUSIVE
@ EPOC_OMODE_SHARE_READERS
Enum< RFSV::errs > copyOnPsion(const char *const, const char *const, void *, cpCallback_t)
Copies a file from the Psion to the Psion.
A helper class for storing intermediate internal information in RFSV16 and RFSV32 .
std::string attr2String(const uint32_t attr)
Converts a file attribute RFSV::file_attribs to human readable format, usable for showing them in dir...
std::unique_ptr< TCPSocket > socket_
static std::string convertSlash(const std::string &name)
Utility method, converts '/' to '\'.
errs
The known error codes.
@ PSI_A_NORMAL
Attributes, valid on EPOC only.
@ PSI_A_READ
Attributes, valid on SIBO only.
@ PSI_A_RDONLY
Attributes, valid on both EPOC and SIBO.
static enum RFSV::errs e2psi[]
int(* cpCallback_t)(void *, uint32_t)
Defines the callback procedure for progress indication of copy operations.
std::deque< class PlpDirent > PlpDir