36#include "ignore-value.h"
38#define RFSV16_MAXDATALEN 852
51fopen(uint32_t attr,
const char *name, uint32_t &handle)
58 a.addStringT(realName.c_str());
64 handle = (long)
a.getWord(0);
71mktemp(uint32_t &handle,
string &tmpname)
82 handle =
a.getWord(0);
83 tmpname =
a.getString(2);
90fcreatefile(uint32_t attr,
const char *name, uint32_t &handle)
96freplacefile(uint32_t attr,
const char *name, uint32_t &handle)
102fopendir(
const char *
const name, uint32_t &handle)
108fclose(uint32_t fileHandle)
111 a.addWord(fileHandle & 0xFFFF);
142 uint16_t bufferLen = dH.
b.
getWord(0);
144 if (dH.
b.
getLen() != bufferLen)
202 a.addStringT(realName.c_str());
209 else if (
a.getLen() == 16) {
229 a.addStringT(realName.c_str());
236fgetattr(
const char *
const name, uint32_t &attr)
240 a.addStringT(realName.c_str());
247 else if (
a.getLen() == 16) {
259 a.addStringT(realName.c_str());
265 else if (
a.getLen() == 16) {
268 const char *p = strrchr(realName.c_str(),
'\\');
272 p = realName.c_str();
277 std::transform(name.begin(), name.end(), name.begin(), ::toupper);
281 e.
size =
a.getDWord(4);
291fsetattr(
const char *name, uint32_t seta, uint32_t unseta)
293 uint32_t statusword =
std2attr(seta) & (~ std2attr(unseta));
294 statusword ^= 0x0000001;
297 a.addWord(statusword & 0xFFFF);
298 a.addWord(bitmask & 0xFFFF);
306dircount(
const char *
const name, uint32_t &count)
346 char name[4] = {
'x',
':',
'\\',
'\0' } ;
347 a.discardFirstBytes(6);
349 name[0] = (char)
a.getByte(5);
356 a.addWord(fileHandle & 0xFFFF);
362 uint16_t version =
a.getWord(0);
363 if ((version < 1) || (version > 2)) {
364 cerr <<
"devlist: not version 1 or 2" << endl;
368 char drive =
a.getByte(64);
369 if (drive >=
'A' && drive <=
'Z') {
370 int shift = (drive -
'A');
371 devbits |= (long) ( 1 << shift );
374 cerr <<
"devlist: non-alphabetic drive letter ("
375 << drive <<
")" << endl;
405 a.addByte(toupper(drive));
417 a.addByte(toupper(drive));
426 int attr =
a.getWord(2);
431 int changeable =
a.getWord(4) ? 32 : 0;
432 int internal = (attr & 0x2000) ? 16 : 0;
436 int variable = (attr & 0x4000) ? 1 : 0;
437 int dualdens = (attr & 0x1000) ? 2 : 0;
438 int formattable = (attr & 0x0800) ? 4 : 0;
439 int protect = ((attr & 0xff) == 6) ? 8 : 0;
447 dinfo.
setName(toupper(drive),
a.getString(14));
485 cerr <<
"rfsv16::getResponse: duff response. "
486 "getBufferStore failed." << endl;
487 }
else if (data.
getWord(0) == 0x2a &&
493 cerr <<
"rfsv16::getResponse: duff response. Size field:" <<
494 data.
getWord(2) <<
" Frame size:" <<
495 data.
getLen()-4 <<
" Result field:" <<
503fread(
const uint32_t handle,
unsigned char *
const buf,
const uint32_t len, uint32_t &count)
506 unsigned char *p = buf;
531 if ((l =
a.getLen()) > 0) {
532 memcpy(p,
a.getString(), l);
536 }
while ((count < len) && (l > 0));
541fwrite(
const uint32_t handle,
const unsigned char *
const buf,
const uint32_t len, uint32_t &count)
544 const unsigned char *p = buf;
547 while (count < len) {
561 a.addBytes(p, nbytes);
592 op.write((
char *)buf, len);
594 if (cb && !cb(ptr, total))
621 ignore_value(write(fd, buf, len));
623 if (cb && !cb(NULL, total))
656 if (cb && !cb(ptr, total))
669 uint32_t handle_from;
690 if (cb && !cb(ptr, total))
708 a.addStringT(realName.c_str());
714fsetsize(uint32_t handle, uint32_t size)
717 a.addWord(handle & 0xffff);
730fseek(
const uint32_t handle,
const int32_t pos,
const uint32_t mode, uint32_t &resultpos)
736 uint32_t calcpos = 0;
764 savpos =
a.getDWord(0);
780 savpos =
a.getDWord(0);
794 realpos =
a.getDWord(0);
800 calcpos = savpos + pos;
807 if (calcpos > realpos) {
820 realpos =
a.getDWord(0);
827mkdir(
const char* dirName)
831 a.addStringT(realName.c_str());
837rmdir(
const char *dirName)
842 string path(dirName);
850 if (path.back() ==
'\\') {
864 return remove(path.c_str());
868rename(
const char *oldName,
const char *newName)
873 a.addStringT(realOldName.c_str());
874 a.addStringT(realNewName.c_str());
880remove(
const char* psionName)
884 a.addStringT(realName.c_str());
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 getSiboTime()
Retrieves the instance's current value in SIBO time format.
void setSiboTime(uint32_t stime)
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.
const char * getString(long pos=0) const
Retrieves the characters 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.
uint32_t getDWord(long pos=0) const
Retrieves the dword at index pos.
Enum< rfsv::errs > fgetattr(const char *const, uint32_t &)
Retrieves attributes of a file on the Psion.
bool sendCommand(enum commands, bufferStore &)
Enum< rfsv::errs > opendir(const uint32_t, const char *const, rfsvDirhandle &)
Open a directory for reading with readdir.
Enum< rfsv::errs > devinfo(const char, PlpDrive &)
Retrieves details about a drive.
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 > pathtest(const char *const)
Checks to see if the directory component of a path or file name exists and is valid.
Enum< rfsv::errs > remove(const char *const)
Removes 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 > closedir(rfsvDirhandle &)
Close a directory, previously opened with opendir.
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.
uint32_t std2attr(const uint32_t)
Enum< rfsv::errs > freplacefile(const uint32_t, const char *const, uint32_t &)
Creates an named file, overwriting an existing file.
Enum< rfsv::errs > copyOnPsion(const char *, const char *, void *, cpCallback_t)
Copies a file from the Psion to 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 > devlist(uint32_t &)
Retrieves available drives on the Psion.
Enum< rfsv::errs > fsetsize(const uint32_t, const uint32_t)
Resizes an open file on the Psion.
uint32_t attr2std(const uint32_t)
Enum< rfsv::errs > setVolumeName(const char, const char *const)
Set the name of a Psion Volume (Drive).
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.
Enum< rfsv::errs > fgetmtime(const char *const, PsiTime &)
Retrieves the modification time of a file on the Psion.
Enum< rfsv::errs > dir(const char *const, PlpDir &)
Reads a directory on the Psion.
Enum< rfsv::errs > getResponse(bufferStore &)
Enum< rfsv::errs > fopendir(const char *const, uint32_t &)
Enum< rfsv::errs > mktemp(uint32_t &, std::string &)
Creates a unique temporary file.
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 > 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 > rmdir(const char *const)
Removes a directory on the Psion.
Enum< rfsv::errs > readdir(rfsvDirhandle &, PlpDirent &)
Read directory entries.
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 > fclose(const uint32_t)
Close a file on the Psion whih was previously opened/created by using fopen , fcreatefile ,...
Enum< rfsv::errs > rename(const char *const, const char *const)
Renames a file on the Psion.
Enum< rfsv::errs > mkdir(const char *const)
Creates a directory 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.
rfsv16(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 '\'.
#define RFSV16_MAXDATALEN
int(* cpCallback_t)(void *, uint32_t)
Defines the callback procedure for progress indication of copy operations.
std::deque< class PlpDirent > PlpDir