38#include "ignore-value.h"
80 char* end = filename + strlen(filename);
81 while (--end > filename)
84 if ((ch ==
'/') || (ch ==
'\\'))
88 fprintf(stderr,
"Checking for existance of %s\n", filename);
92 fprintf(stderr,
"Creating dir %s\n", filename);
98 fprintf(stderr,
" -> Failed: %s\n", (
const char*)res);
111 if (destptr ==
nullptr)
113 if (destptr[0] ==
'!')
121 memcpy(dest, destptr, len);
128 fprintf(stderr,
"Setting main drive to %c\n",
m_drive);
133 "Copying %u bytes to %s\n",
136 printf(
"%s\n", msgbuf);
150 strcpy(srcName,
"/tmp/plptools-sis-XXXXXX");
151 int fd = mkstemp(srcName);
155 "Couldn't create temp file: %s\n", strerror(errno));
160 fprintf(stderr,
"Storing in %s\n", srcName);
161 ssize_t written = write(fd, buf, len);
162 int close_res = close(fd);
163 bool write_ok = written == len && close_res == 0;
171 fprintf(stderr,
" -> Success.\n");
175 fprintf(stderr,
" -> Fail: %s\n", (
const char*)res);
192 printf(
"Info:\n%.*s\n",
198 printf(
"Continue\n");
199 ignore_value(fgets(readbuf,
sizeof(readbuf), stdin));
202 printf(
"(Install next file?) [Y]es/No\n");
203 char *res = fgets(readbuf,
sizeof(readbuf), stdin);
204 if (!res || strchr(
"Nn", readbuf[0]))
211 printf(
"(Continue installation?) [Y]es/No\n");
212 char *res = fgets(readbuf,
sizeof(readbuf), stdin);
213 if (!res || strchr(
"Nn", readbuf[0]))
228 fprintf(stderr,
"Recursive sis file...\n");
238 "Could not read contained sis file, rc = %d\n", rc);
244 rc = installer.
run(&sisFile, buf2, len,
m_file);
251 "Updated drive to %c from recursive sis file\n",
258 fprintf(stderr,
"Run %.*s during installation/remove\n",
263 fprintf(stderr,
"Running the app will create %.*s\n",
270#define SYSTEMINSTALL "c:\\system\\install\\"
284 while (!files.empty())
288 fprintf(stderr,
"Loading sis file `%s'\n", file.
getName());
302 strcpy(srcName,
"/tmp/plptools-sis-XXXXXX");
303 int fd = mkstemp(srcName);
306 fprintf(stderr,
"Couldn't create temp file: %s\n", strerror(errno));
312 fprintf(stderr,
"Copying from %s to temp file %s\n", name, srcName);
316 off_t fileLen = lseek(fd, 0, SEEK_END);
318 fprintf(stderr,
"Read %d bytes from the Psion file %s\n",
320 lseek(fd, SEEK_SET, 0);
321 uint8_t* sisbuf =
new uint8_t[fileLen];
322 int rc = read(fd, sisbuf, fileLen);
330 fprintf(stderr,
" Ok.\n");
356 fprintf(stderr,
"Removing file component %s.\n", dest);
363 return run(file, buf, len, 0);
380 _(
"You have only one language: %s"),
382 printf(
"%s\n", msgbuf);
387 printf(
"Select a language (%d alternatives):\n", n);
388 for (
int i = 0; i < n; ++i)
401 fprintf(stderr,
"Forcing language to %ld\n", lang);
405 sprintf(msgbuf,
_(
"Installing component: `%s'"), compName);
406 printf(
"%s\n", msgbuf);
421 fprintf(stderr,
"Found %d requisites, of some sort.\n", n);
422 for (
int i = 0; i < n; ++i)
427 " Check if app with uid %08x exists with version >= %d.%d\n",
435 "Checking if this app (uid %08x) exists with a version less than %d.%d.\n",
440 bool uninstallFirst =
false;
449 uninstallFirst =
true;
455 uninstallFirst =
true;
461 uninstallFirst =
true;
475 fprintf(stderr,
"Already installed, but 0?\n");
478 sprintf(msgbuf,
"%s",
_(
"Uninstalling the previous version first."));
479 printf(
"%s\n", msgbuf);
488 fprintf(stderr,
"Found %d files.\n", n);
490 int nCopiedFiles = 0;
492 bool skipnext =
false;
493 bool aborted =
false;
494 while (!aborted && (n-- > 0))
523 "Installed %d files of %d, cutting at offset %u.\n",
527 if (nCopiedFiles == 0)
539 while (compName[namelen] != 0)
541 if (compName[namelen] ==
' ')
545 sprintf(resname,
"C:\\System\\Install\\%.*s.sis", namelen, compName);
547 fprintf(stderr,
"Creating residual sis file %s\n", resname);
557 uint32_t devbits = 0;
563 for (
int i = 0; i < 26; i++)
566 if (((devbits & 1) != 0) &&
570 if ((mediaType == 3) || (mediaType == 5))
572 drivelist[ndrives] =
'A' + i;
573 printf(
"%c: %lud bytes free, %lud bytes total\n",
583 drivelist[ndrives] = 0;
588 printf(
"Selecting the only drive %c\n",
m_drive);
590 else if (ndrives == 1)
594 printf(
"Selecting the only drive %c\n",
m_drive);
600 printf(
"Please select a drive\n");
605 if (fgets(readbuf, 2, stdin) == NULL)
607 printf(
"please enter a drive");
611 if ((ch >=
'a' && ch <=
'z') || (ch >=
'A' && ch <=
'Z'))
614 if (!strchr(drivelist,
m_drive))
617 printf(
"Please select a valid drive: %s\n", drivelist);
638 fprintf(stderr,
"Uninstalling %d files, from a total of %d.\n",
669 fprintf(stderr,
"Recursive sis file...\n");
672 uint8_t* buf2 =
m_buf + fileptr;
680 "Could not read contained sis file, rc = %d\n", rc);
686 rc = installer.
run(&sisFile, buf2, len,
m_file);
693 "Updated drive to %c from recursive sis file\n",
Wrapper class featuring range-checking and string representation of enumerated values.
A class, representing a directory entry of the Psion.
const char * getName()
Retrieve the file name of a directory entry.
A class representing information about a Disk drive on the psion.
uint64_t getSize()
Retrieve the total capacity of the drive.
uint32_t getMediaType()
Retrieve the media type of the drive.
uint64_t getSpace()
Retrieve the free capacity on the drive.
Semi smart proxy for communicating with a Psion.
virtual Enum< rfsv::errs > dir(const char *dir, PlpDir &files)
virtual Enum< rfsv::errs > devinfo(const char drive, PlpDrive &plpDrive)
virtual Enum< rfsv::errs > devlist(uint32_t &devbits)
virtual void remove(const char *name)
virtual Enum< rfsv::errs > mkdir(const char *dir)
virtual Enum< rfsv::errs > copyToPsion(const char *const from, const char *const to, void *, cpCallback_t func)
virtual Enum< rfsv::errs > copyFromPsion(const char *const from, int fd, cpCallback_t func)
Information about a file component in a SIS file.
uint8_t * getFilePtr(int fileNo)
Return a pointer to the file data for the file for the specified language.
uint32_t m_flags
1 if multiple language versions, otherwise 0.
uint32_t m_fileDetails
If file type is 1:
uint32_t m_fileType
Type of file.
void setMainDrive(char drive)
The top level container of a SIS file.
void setDrive(char drive)
Set the installed drive.
SisRC fillFrom(uint8_t *buf, off_t len)
Populate the fields.
SISReqRecord * m_reqRecords
void setFiles(int nFiles)
Set the number of installed files.
SisRC compareApp(SISFile *other)
Compare uid and version number of this file, with another.
SISFileRecord * m_fileRecords
void setLanguage(int lang)
Set the selected installation language.
int getLanguage()
Return the currently selected installation language.
uint32_t getResidualEnd()
Get the number of bytes that should be copied to the residual sis file on the psion.
uint8_t * getName()
Get the name of this component, in the selected language.
void selectDrive()
Ask the user which drive to install to.
void loadPsionSis(const char *name)
SISFileLink * m_installed
void removeFile(SISFileRecord *fileRecord)
void copyBuf(const uint8_t *buf, int len, char *name)
Store the contents of a buffer in a file on the Psion.
void setPsion(Psion *psion)
Set the Psion manager.
void uninstallFile(SISFileRecord *fileRecord)
int installFile(SISFileRecord *fileRecord)
void createDirs(char *filename)
SisRC run(SISFile *file, uint8_t *buf, off_t len)
void copyFile(SISFileRecord *fileRecord)
Copy a file to the Psion.
void uninstall(SISFile *sisFile)
void setInstalled(SISFileLink *installed)
Set the base pointer to the list of already installed applications, so we don't have to scan it for e...
Information about an application that must be installed prior to the current one.
static int checkAbortHash(void *, uint32_t)
static int continueRunning
std::deque< class PlpDirent > PlpDir
static int checkAbortHash(void *, uint32_t)
static int continueRunning