40#include "ignore-value.h"
42#define RFSV16_MAXDATALEN 852
59 a.addStringT(realName.c_str());
66 handle =
static_cast<long>(
a.getWord(0));
83 handle =
a.getWord(0);
84 tmpname =
a.getString(2);
104 a.addWord(fileHandle & 0xFFFF);
136 uint16_t bufferLen = dH.
b.
getWord(0);
138 if (dH.
b.
getLen() != bufferLen) {
195 a.addStringT(realName.c_str());
203 }
else if (
a.getLen() == 16) {
221 a.addStringT(realName.c_str());
231 a.addStringT(realName.c_str());
239 }
else if (
a.getLen() == 16) {
240 attr =
attr2std(
static_cast<long>(
a.getWord(2)));
249 a.addStringT(realName.c_str());
255 else if (
a.getLen() == 16) {
258 const char *p = strrchr(realName.c_str(),
'\\');
262 p = realName.c_str();
267 std::transform(filename.begin(), filename.end(), filename.begin(), ::toupper);
271 e.
size =
a.getDWord(4);
281 uint32_t statusword =
std2attr(seta) & (~ std2attr(unseta));
282 statusword ^= 0x0000001;
285 a.addWord(statusword & 0xFFFF);
286 a.addWord(bitmask & 0xFFFF);
335 char name[4] = {
'x',
':',
'\\',
'\0' } ;
336 a.discardFirstBytes(6);
338 name[0] =
static_cast<char>(
a.getByte(5));
346 a.addWord(fileHandle & 0xFFFF);
352 uint16_t version =
a.getWord(0);
353 if ((version < 1) || (version > 2)) {
354 cerr <<
"devlist: not version 1 or 2" << endl;
358 char drive =
a.getByte(64);
359 if (drive >=
'A' && drive <=
'Z') {
360 int shift = (drive -
'A');
361 devbits |=
static_cast<long>(1 << shift);
363 cerr <<
"devlist: non-alphabetic drive letter ("
364 << drive <<
")" << endl;
393 a.addByte(toupper(drive));
407 a.addByte(toupper(drive));
418 int attr =
a.getWord(2);
423 int changeable =
a.getWord(4) ? 32 : 0;
424 int internal = (attr & 0x2000) ? 16 : 0;
428 int variable = (attr & 0x4000) ? 1 : 0;
429 int dualdens = (attr & 0x1000) ? 2 : 0;
430 int formattable = (attr & 0x0800) ? 4 : 0;
431 int protect = ((attr & 0xff) == 6) ? 8 : 0;
439 dinfo.
setName(toupper(drive),
a.getString(14));
457 result =
socket_->sendBufferStore(
a);
460 result =
socket_->sendBufferStore(
a);
473 if (
socket_->getBufferStore(data) != 1) {
474 cerr <<
"RFSV16::getResponse: duff response. "
475 "getBufferStore failed." << endl;
476 }
else if (data.
getWord(0) == 0x2a &&
482 cerr <<
"RFSV16::getResponse: duff response. Size field:" <<
483 data.
getWord(2) <<
" Frame size:" <<
484 data.
getLen()-4 <<
" Result field:" <<
493 unsigned char *p = buf;
520 if ((l =
a.getLen()) > 0) {
521 memcpy(p,
a.getString(), l);
525 }
while ((count < len) && (l > 0));
530 const unsigned char *
const buf,
534 const unsigned char *p = buf;
537 while (count < len) {
551 a.addBytes(p, nbytes);
582 op.write(
reinterpret_cast<char *
>(buf),
static_cast<std::streamsize
>(len));
585 if (cb && !cb(ptr, total)) {
613 ignore_value(write(fd, buf, len));
615 if (cb && !cb(NULL, total)) {
650 if (cb && !cb(ptr, total)) {
662 uint32_t handle_from;
685 if (cb && !cb(ptr, total)) {
703 a.addStringT(realName.c_str());
710 a.addWord(handle & 0xffff);
728 uint32_t calcpos = 0;
759 savpos =
a.getDWord(0);
777 savpos =
a.getDWord(0);
793 realpos =
a.getDWord(0);
799 calcpos = savpos + pos;
806 if (calcpos > realpos) {
822 realpos =
a.getDWord(0);
831 a.addStringT(realName.c_str());
840 string path(dirName);
848 if (path.back() ==
'\\') {
862 return remove(path.c_str());
869 a.addStringT(realOldName.c_str());
870 a.addStringT(realNewName.c_str());
878 a.addStringT(realName.c_str());
A generic container for an array of bytes.
const char * getString(long pos=0) const
Retrieves the characters at index pos.
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 addWord(int w)
Appends a word to the content of this instance.
unsigned long getLen() const
Retrieves the length of a BufferStore.
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 getSiboTime()
Retrieves the instance's current value in SIBO time format.
void setSiboTime(uint32_t stime)
Modifies the value of this instance.
Enum< RFSV::errs > mktemp(uint32_t &, std::string &)
Creates a unique temporary file.
Enum< RFSV::errs > getResponse(BufferStore &)
Enum< RFSV::errs > devlist(uint32_t &)
Retrieves available drives on the Psion.
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 > freplacefile(const uint32_t, const char *const, uint32_t &)
Creates an named file, overwriting an existing file.
Enum< RFSV::errs > fsetsize(const uint32_t, const uint32_t)
Resizes an open file on the Psion.
Enum< RFSV::errs > copyOnPsion(const char *, const char *, void *, cpCallback_t)
Copies a file from the Psion to the Psion.
Enum< RFSV::errs > rmdir(const char *const)
Removes a directory on the Psion.
Enum< RFSV::errs > closedir(RFSVDirHandle &)
Close a directory, previously opened with opendir.
Enum< RFSV::errs > readdir(RFSVDirHandle &, PlpDirent &)
Read directory entries.
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 char *const, uint32_t &)
Enum< RFSV::errs > setVolumeName(const char, const char *const)
Set the name of a Psion Volume (Drive).
Enum< RFSV::errs > fopen(const uint32_t, const char *const, uint32_t &)
Opens a file.
Enum< RFSV::errs > fsetattr(const char *const, const uint32_t seta, const uint32_t unseta)
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 > rename(const char *const, const char *const)
Renames a file on the Psion.
Enum< RFSV::errs > dir(const char *const, PlpDir &)
Reads a directory on the Psion.
Enum< RFSV::errs > opendir(const uint32_t, const char *const, RFSVDirHandle &)
Open a directory for reading with readdir.
Enum< RFSV::errs > fgetmtime(const char *const, PsiTime &)
Retrieves the modification time of a file on the Psion.
uint32_t std2attr(const uint32_t)
Enum< RFSV::errs > mkdir(const char *const)
Creates a directory on the Psion.
Enum< RFSV::errs > fcreatefile(const uint32_t, const char *const, uint32_t &)
Creates a named file.
Enum< RFSV::errs > fsetmtime(const char *const, const PsiTime)
Sets the modification time of 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.
bool sendCommand(enum commands, BufferStore &)
Enum< RFSV::errs > fgeteattr(const char *const, PlpDirent &)
Retrieves attributes, size and modification time 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.
RFSV16(std::unique_ptr< TCPSocket > socket)
Enum< RFSV::errs > fgetattr(const char *const, uint32_t &)
Retrieves attributes of a file on the Psion.
Enum< RFSV::errs > copyToPsion(const char *const, const char *const, void *, cpCallback_t)
Copies a file from local machine to the Psion.
uint32_t attr2std(const uint32_t)
Enum< RFSV::errs > pathtest(const char *const)
Checks to see if the directory component of a path or file name exists and is valid.
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 > remove(const char *const)
Removes a file on the Psion.
Enum< RFSV::errs > devinfo(const char, Drive &)
Retrieves details about a drive.
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.
#define RFSV16_MAXDATALEN
int(* cpCallback_t)(void *, uint32_t)
Defines the callback procedure for progress indication of copy operations.
std::deque< class PlpDirent > PlpDir