aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/rfsv.h7
-rw-r--r--lib/rfsv16.cc21
-rw-r--r--lib/rfsv16.h20
-rw-r--r--lib/rfsv32.cc20
-rw-r--r--lib/rfsv32.h4
-rw-r--r--lib/rpcs.cc6
-rw-r--r--lib/rpcs.h30
7 files changed, 69 insertions, 39 deletions
diff --git a/lib/rfsv.h b/lib/rfsv.h
index dbed2c9..c497f67 100644
--- a/lib/rfsv.h
+++ b/lib/rfsv.h
@@ -363,14 +363,15 @@ public:
/**
* Retrieves details about a drive.
*
- * @param dev An integer, representing the drive to get details from.
+ * @param drive The drive character of the drive to get details from
+ * (e.g: 'C', 'D' etc.).
* (0 represents A:, 1 is B: and so on ...)
- * @param drive A @ref PlpDrive object which is filled with the drive's
+ * @param dinfo A @ref PlpDrive object which is filled with the drive's
* information upon return.
*
* @returns A Psion error code (One of enum @ref #errs ).
*/
- virtual Enum<errs> devinfo(const u_int32_t dev, PlpDrive &drive) = 0;
+ virtual Enum<errs> devinfo(const char drive, PlpDrive &dinfo) = 0;
/**
* Reads from a file on the Psion.
diff --git a/lib/rfsv16.cc b/lib/rfsv16.cc
index 30c3673..2fda1a6 100644
--- a/lib/rfsv16.cc
+++ b/lib/rfsv16.cc
@@ -423,7 +423,7 @@ static int sibo_dattr[] = {
};
Enum<rfsv::errs> rfsv16::
-devinfo(const u_int32_t devnum, PlpDrive &drive)
+devinfo(const char drive, PlpDrive &dinfo)
{
bufferStore a;
Enum<rfsv::errs> res;
@@ -434,9 +434,10 @@ devinfo(const u_int32_t devnum, PlpDrive &drive)
// (which we ignore), then do a STATUSDEVICE to get the info.
a.init();
- a.addByte((char) (devnum + 'A')); // Name 1
+ a.addByte(toupper(drive)); // Name 1
a.addByte(':');
a.addByte(0x00);
+
a.addByte(0x00); // No name 2
a.addByte(0x00); // No name 3
if (!sendCommand(PARSE, a))
@@ -447,7 +448,7 @@ devinfo(const u_int32_t devnum, PlpDrive &drive)
}
a.init();
- a.addByte((char) (devnum + 'A')); // Name 1
+ a.addByte(toupper(drive)); // Name 1
a.addByte(':');
a.addByte('\\');
a.addByte(0x00);
@@ -460,26 +461,26 @@ devinfo(const u_int32_t devnum, PlpDrive &drive)
int attr = a.getWord(2);
attr = sibo_dattr[a.getWord(2) & 0xff];
- drive.setMediaType(attr);
+ dinfo.setMediaType(attr);
attr = a.getWord(2);
int changeable = a.getWord(4) ? 32 : 0;
int internal = (attr & 0x2000) ? 16 : 0;
- drive.setDriveAttribute(changeable | internal);
+ dinfo.setDriveAttribute(changeable | internal);
int variable = (attr & 0x4000) ? 1 : 0;
int dualdens = (attr & 0x1000) ? 2 : 0;
int formattable = (attr & 0x0800) ? 4 : 0;
int protect = ((attr & 0xff) == 6) ? 8 : 0;
- drive.setMediaAttribute(variable|dualdens|formattable|protect);
+ dinfo.setMediaAttribute(variable|dualdens|formattable|protect);
- drive.setUID(0);
- drive.setSize(a.getDWord(6), 0);
- drive.setSpace(a.getDWord(10), 0);
+ dinfo.setUID(0);
+ dinfo.setSize(a.getDWord(6), 0);
+ dinfo.setSpace(a.getDWord(10), 0);
- drive.setName('A' + devnum, a.getString(14));
+ dinfo.setName(toupper(drive), a.getString(14));
return res;
diff --git a/lib/rfsv16.h b/lib/rfsv16.h
index 2cd4393..8682818 100644
--- a/lib/rfsv16.h
+++ b/lib/rfsv16.h
@@ -56,7 +56,7 @@ public:
Enum<rfsv::errs> fsetattr(const char * const, const u_int32_t seta, const u_int32_t unseta);
Enum<rfsv::errs> dircount(const char * const, u_int32_t &);
Enum<rfsv::errs> devlist(u_int32_t &);
- Enum<rfsv::errs> devinfo(const u_int32_t, PlpDrive &);
+ Enum<rfsv::errs> devinfo(const char, PlpDrive &);
Enum<rfsv::errs> fread(const u_int32_t, unsigned char * const, const u_int32_t, u_int32_t &);
Enum<rfsv::errs> fwrite(const u_int32_t, const unsigned char * const, const u_int32_t, u_int32_t &);
Enum<rfsv::errs> copyFromPsion(const char * const, const char * const, void *, cpCallback_t);
@@ -100,7 +100,7 @@ private:
SFDATE = 40,
RESPONSE = 42
};
-
+
enum fopen_attrib {
P_FOPEN = 0x0000, /* Open file */
P_FCREATE = 0x0001, /* Create file */
@@ -120,19 +120,19 @@ private:
};
enum status_enum {
- P_FAWRITE = 0x0001, /* can the file be written to? */
- P_FAHIDDEN = 0x0002, /* set if file is hidden */
+ P_FAWRITE = 0x0001, /* can the file be written to? */
+ P_FAHIDDEN = 0x0002, /* set if file is hidden */
P_FASYSTEM = 0x0004, /* set if file is a system file */
- P_FAVOLUME = 0x0008, /* set if the name is a volume name */
- P_FADIR = 0x0010, /* set if file is a directory file */
- P_FAMOD = 0x0020, /* has the file been modified? */
- P_FAREAD = 0x0100, /* can the file be read? */
+ P_FAVOLUME = 0x0008, /* set if the name is a volume name */
+ P_FADIR = 0x0010, /* set if file is a directory file */
+ P_FAMOD = 0x0020, /* has the file been modified? */
+ P_FAREAD = 0x0100, /* can the file be read? */
P_FAEXEC = 0x0200, /* is the file executable? */
- P_FASTREAM = 0x0400, /* is the file a byte stream file? */
+ P_FASTREAM = 0x0400, /* is the file a byte stream file? */
P_FATEXT = 0x0800, /* is it a text file? */
P_FAMASK = 0x0f3f /* All of the above */
};
-
+
/**
* Private constructor. Shall be called by
* rfsvfactory only.
diff --git a/lib/rfsv32.cc b/lib/rfsv32.cc
index 7849d97..a28d2f2 100644
--- a/lib/rfsv32.cc
+++ b/lib/rfsv32.cc
@@ -360,24 +360,24 @@ devlist(u_int32_t &devbits)
}
Enum<rfsv::errs> rfsv32::
-devinfo(const u_int32_t dev, PlpDrive &drive)
+devinfo(const char drive, PlpDrive &dinfo)
{
bufferStore a;
Enum<rfsv::errs> res;
- a.addDWord(dev);
+ a.addDWord(toupper(drive) - 'A');
if (!sendCommand(DRIVE_INFO, a))
return E_PSI_FILE_DISC;
res = getResponse(a);
if (res == E_PSI_GEN_NONE) {
- drive.setMediaType(a.getDWord(0));
- drive.setDriveAttribute(a.getDWord(8));
- drive.setMediaAttribute(a.getDWord(12));
- drive.setUID(a.getDWord(16));
- drive.setSize(a.getDWord(20), a.getDWord(24));
- drive.setSpace(a.getDWord(28), a.getDWord(32));
+ dinfo.setMediaType(a.getDWord(0));
+ dinfo.setDriveAttribute(a.getDWord(8));
+ dinfo.setMediaAttribute(a.getDWord(12));
+ dinfo.setUID(a.getDWord(16));
+ dinfo.setSize(a.getDWord(20), a.getDWord(24));
+ dinfo.setSpace(a.getDWord(28), a.getDWord(32));
a.addByte(0);
- drive.setName('A' + dev, a.getString(40));
+ dinfo.setName(toupper(drive), a.getString(40));
}
return res;
}
@@ -771,7 +771,7 @@ Enum<rfsv::errs> rfsv32::
setVolumeName(const char drive , const char * const name)
{
bufferStore a;
- a.addDWord(drive - 'A');
+ a.addDWord(toupper(drive) - 'A');
a.addWord(strlen(name));
a.addStringT(name);
if (!sendCommand(SET_VOLUME_LABEL, a))
diff --git a/lib/rfsv32.h b/lib/rfsv32.h
index 9baefaa..05da60c 100644
--- a/lib/rfsv32.h
+++ b/lib/rfsv32.h
@@ -70,7 +70,7 @@ public:
Enum<rfsv::errs> fclose(const u_int32_t);
Enum<rfsv::errs> devlist(u_int32_t &);
- Enum<rfsv::errs> devinfo(const u_int32_t, PlpDrive&);
+ Enum<rfsv::errs> devinfo(const char, PlpDrive&);
Enum<rfsv::errs> opendir(const u_int32_t, const char * const, rfsvDirhandle &);
Enum<rfsv::errs> readdir(rfsvDirhandle &, PlpDirent &);
Enum<rfsv::errs> closedir(rfsvDirhandle &);
@@ -78,7 +78,7 @@ public:
u_int32_t opMode(const u_int32_t);
private:
-
+
enum file_attrib {
EPOC_ATTR_RONLY = 0x0001,
EPOC_ATTR_HIDDEN = 0x0002,
diff --git a/lib/rpcs.cc b/lib/rpcs.cc
index 2e1288d..6cf7fee 100644
--- a/lib/rpcs.cc
+++ b/lib/rpcs.cc
@@ -247,12 +247,14 @@ queryProgram(const char *program)
}
Enum<rfsv::errs> rpcs::
-formatOpen(const char *drive, int &handle, int &count)
+formatOpen(const char drive, int &handle, int &count)
{
Enum<rfsv::errs> res;
bufferStore a;
- a.addStringT(drive);
+ a.addByte(toupper(drive));
+ a.addByte(':');
+ a.addByte(0);
if (!sendCommand(FORMAT_OPEN, a))
return rfsv::E_PSI_FILE_DISC;
if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE)
diff --git a/lib/rpcs.h b/lib/rpcs.h
index 68eb3d5..b2fb09d 100644
--- a/lib/rpcs.h
+++ b/lib/rpcs.h
@@ -228,8 +228,34 @@ public:
Enum<rfsv::errs> stopProgram(const char *);
Enum<rfsv::errs> queryProgram(const char *);
- Enum<rfsv::errs> formatOpen(const char *, int &, int &);
- Enum<rfsv::errs> formatRead(int);
+
+ /**
+ * Starts formatting a drive.
+ *
+ * This function is working with both SIBO and EPOC
+ * devices. After calling formatOpen, formatRead should
+ * be called n times with the returned handle where n is
+ * the value of the returned parameter count.
+ *
+ * @param drive The drive character to format (e.g: 'C', 'D' etc).
+ * @param handle The handle for calling formatRead is returned here.
+ * @param count The number of required calls to formatRead is returned
+ * here.
+ *
+ * @returns A psion error code. 0 = Ok.
+ */
+ Enum<rfsv::errs> formatOpen(const char drive, int &handle, int &count);
+
+ /**
+ * Continues a running format.
+ *
+ * This function is working with both SIBO and EPOC
+ * devices. Call this function with the handle, returned by formatOpen.
+ *
+ * @returns A psion error code. 0 = Ok.
+ */
+ Enum<rfsv::errs> formatRead(int handle);
+
Enum<rfsv::errs> getUniqueID(const char *, long &);
/**