35#include "ignore-value.h"
48fopen(uint32_t attr,
const char *name, uint32_t &handle)
54 a.addString(n.c_str());
59 handle =
a.getDWord(0);
66mktemp(uint32_t &handle,
string &tmpname)
73 handle =
a.getDWord(0);
74 tmpname =
a.getString(6);
80fcreatefile(uint32_t attr,
const char *name, uint32_t &handle)
86 a.addString(n.c_str());
91 handle =
a.getDWord(0);
96freplacefile(
const uint32_t attr,
const char *
const name, uint32_t &handle)
102 a.addString(n.c_str());
107 handle =
a.getDWord(0);
112fopendir(
const uint32_t attr,
const char *
const name, uint32_t &handle)
118 a.addString(n.c_str());
122 if (!res &&
a.getLen() == 4)
123 handle =
a.getDWord(0);
174 for (
int i = 0; i < longLen; i++, d++)
205opMode(
const uint32_t mode)
223 a.addString(n.c_str());
241 a.addString(n.c_str());
248fgetattr(
const char *
const name, uint32_t &attr)
253 a.addString(n.c_str());
269 a.addString(n.c_str());
270 const char *p = strrchr(n.c_str(),
'\\');
286 e.
size =
a.getDWord(8);
287 e.
UID =
PlpUID(
a.getDWord(20),
a.getDWord(24),
a.getDWord(28));
295fsetattr(
const char *
const name,
const uint32_t seta,
const uint32_t unseta)
302 a.addString(n.c_str());
309dircount(
const char *
const name, uint32_t &count)
325 while (
a.getLen() > 16) {
326 int d = 36 +
a.getDWord(32);
332 a.discardFirstBytes(d);
353 for (
int i = 25; i >= 0; i--) {
355 if (
a.getByte(i) != 0)
368 a.addDWord(toupper(drive) -
'A');
377 dinfo.
setSize(
a.getDWord(20),
a.getDWord(24));
378 dinfo.
setSpace(
a.getDWord(28),
a.getDWord(32));
380 dinfo.
setName(toupper(drive),
a.getString(40));
426fread(
const uint32_t handle,
unsigned char *
const buf,
const uint32_t len, uint32_t &count)
432 unsigned char *p = buf;
441 if ((l =
a.getLen()) > 0) {
442 memcpy(p,
a.getString(), l);
447 }
while ((count < len) && (l > 0));
452fwrite(
const uint32_t handle,
const unsigned char *
const buf,
const uint32_t len, uint32_t &count)
455 const unsigned char *p = buf;
473 }
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))
554 if (cb && !cb(ptr, total))
567 uint32_t handle_from;
603 if (cb && !cb(ptr, total))
622 a.addString(n.c_str());
629fsetsize(uint32_t handle, uint32_t size)
645fseek(
const uint32_t handle,
const int32_t pos,
const uint32_t mode, uint32_t &resultpos)
650 uint32_t calcpos = 0;
679 savpos =
a.getDWord(0);
695 savpos =
a.getDWord(0);
703 a.addDWord(savpos + mypos);
719 realpos =
a.getDWord(0);
725 calcpos = savpos + mypos;
732 if (calcpos > realpos) {
748 realpos =
a.getDWord(0);
755mkdir(
const char *name)
759 if (n.find_last_of(
'\\') != (n.size() - 1))
762 a.addString(n.c_str());
769rmdir(
const char *name)
773 if (n.find_last_of(
'\\') != (n.size() - 1))
776 a.addString(n.c_str());
783rename(
const char *oldname,
const char *newname)
788 a.addWord(on.size());
789 a.addString(on.c_str());
790 a.addWord(nn.size());
791 a.addString(nn.c_str());
803 a.addString(n.c_str());
813 a.addDWord(toupper(drive) -
'A');
814 a.addWord(strlen(name));
872 cerr <<
"FATAL: invalid error-code" << endl;
873 cerr <<
"status: " << istatus <<
" " << hex << istatus << endl;
Wrapper class featuring range-checking and string representation of enumerated values.
A class, representing a directory entry of the Psion.
A class representing information about a Disk drive on the psion.
void setUID(uint32_t uid)
void setSpace(uint32_t spaceLo, uint32_t spaceHi)
void setSize(uint32_t sizeLo, uint32_t sizeHi)
void setMediaAttribute(uint32_t attr)
void setName(char drive, const char *const volname)
void setMediaType(uint32_t type)
void setDriveAttribute(uint32_t attr)
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.
A class for dealing with sockets.
int getBufferStore(bufferStore &a, bool wait=true)
Receive data into a bufferStore .
bool sendBufferStore(const bufferStore &a)
Sends data from a bufferStore .
A generic container for an array of bytes.
void discardFirstBytes(int len=0)
Removes bytes from the start of the buffer.
void init()
Initializes the bufferStore.
uint16_t getWord(long pos=0) const
Retrieves the word 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.
uint32_t getDWord(long pos=0) const
Retrieves the dword at index pos.
unsigned char getByte(long pos=0) const
Retrieves the byte at index pos.
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 > fclose(const uint32_t)
Close a file on the Psion whih was previously opened/created by using fopen , fcreatefile ,...
bool sendCommand(enum commands, bufferStore &)
Enum< rfsv::errs > readdir(rfsvDirhandle &, PlpDirent &)
Read directory entries.
Enum< rfsv::errs > fopen(const uint32_t, const char *const, uint32_t &)
Opens a file.
Enum< rfsv::errs > fcreatefile(const uint32_t, const char *const, uint32_t &)
Creates a named file.
Enum< rfsv::errs > opendir(const uint32_t, const char *const, rfsvDirhandle &)
Open a directory for reading with readdir.
Enum< rfsv::errs > rmdir(const char *const)
Removes a directory 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 > dircount(const char *const, uint32_t &)
Counts number of entries in a directory.
Enum< rfsv::errs > fgeteattr(const char *const, PlpDirent &)
Retrieves attributes, size and modification time of a file on the Psion.
Enum< rfsv::errs > remove(const char *const)
Removes a file on the Psion.
Enum< rfsv::errs > rename(const char *const, const char *const)
Renames a file on the Psion.
uint32_t opMode(const uint32_t)
Converts an open-mode (A combination of the PSI_O_ constants.) from generic representation to the mac...
Enum< rfsv::errs > err2psierr(int32_t)
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 > fread(const uint32_t, unsigned char *const, const uint32_t, uint32_t &)
Reads from a file on the Psion.
uint32_t std2attr(const uint32_t)
Enum< rfsv::errs > fgetattr(const char *const, uint32_t &)
Retrieves attributes of a file on the Psion.
Enum< rfsv::errs > devinfo(const char, PlpDrive &)
Retrieves details about a drive.
Enum< rfsv::errs > mkdir(const char *const)
Creates a directory on the Psion.
Enum< rfsv::errs > mktemp(uint32_t &, std::string &)
Creates a unique temporary file.
Enum< rfsv::errs > fsetattr(const char *const, const uint32_t, 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 > copyFromPsion(const char *const, const char *const, void *, cpCallback_t)
Copies a file from the Psion to the local machine.
Enum< rfsv::errs > copyOnPsion(const char *const, const char *const, void *, cpCallback_t)
Copies a file from the Psion to the Psion.
Enum< rfsv::errs > fsetmtime(const char *const, PsiTime const)
Sets the modification time of a file on the Psion.
Enum< rfsv::errs > getResponse(bufferStore &)
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 > fgetmtime(const char *const, PsiTime &)
Retrieves the modification time of a file on the Psion.
uint32_t attr2std(const uint32_t)
Enum< rfsv::errs > closedir(rfsvDirhandle &)
Close a directory, previously opened with opendir.
Enum< rfsv::errs > freplacefile(const uint32_t, const char *const, uint32_t &)
Creates an named file, overwriting an existing file.
@ EPOC_OMODE_SHARE_READERS
@ EPOC_OMODE_SHARE_EXCLUSIVE
Enum< rfsv::errs > dir(const char *const, PlpDir &)
Reads a directory on the Psion.
Enum< rfsv::errs > devlist(uint32_t &)
Retrieves available drives on the Psion.
Enum< rfsv::errs > setVolumeName(const char, const char *const)
Set the name of a Psion Volume (Drive).
rfsv32(TCPSocket *)
Private constructor.
A helper class for storing intermediate internal information in rfsv16 and rfsv32 .
errs
The known error codes.
std::string attr2String(const uint32_t attr)
Converts a file attribute rfsv::file_attribs to human readable format, usable for showing them in dir...
@ PSI_A_NORMAL
Attributes, valid on EPOC only.
@ PSI_A_RDONLY
Attributes, valid on both EPOC and SIBO.
@ PSI_A_READ
Attributes, valid on SIBO only.
static std::string convertSlash(const std::string &name)
Utility method, converts '/' to '\'.
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