40#include "ignore-value.h"
82 char* end = filename + strlen(filename);
83 while (--end > filename)
86 if ((ch ==
'/') || (ch ==
'\\'))
90 fprintf(stderr,
"Checking for existance of %s\n", filename);
94 fprintf(stderr,
"Creating dir %s\n", filename);
100 fprintf(stderr,
" -> Failed: %s\n", (
const char*)res);
113 if (destptr ==
nullptr)
115 if (destptr[0] ==
'!')
123 memcpy(dest, destptr, len);
130 fprintf(stderr,
"Setting main drive to %c\n",
m_drive);
135 "Copying %u bytes to %s\n",
138 printf(
"%s\n", msgbuf);
152 strcpy(srcName,
"/tmp/plptools-sis-XXXXXX");
153 int fd = mkstemp(srcName);
157 "Couldn't create temp file: %s\n", strerror(errno));
162 fprintf(stderr,
"Storing in %s\n", srcName);
163 ssize_t written = write(fd, buf, len);
164 int close_res = close(fd);
165 bool write_ok = written == len && close_res == 0;
173 fprintf(stderr,
" -> Success.\n");
177 fprintf(stderr,
" -> Fail: %s\n", (
const char*)res);
194 printf(
"Info:\n%.*s\n",
200 printf(
"Continue\n");
201 ignore_value(fgets(readbuf,
sizeof(readbuf), stdin));
204 printf(
"(Install next file?) [Y]es/No\n");
205 char *res = fgets(readbuf,
sizeof(readbuf), stdin);
206 if (!res || strchr(
"Nn", readbuf[0]))
213 printf(
"(Continue installation?) [Y]es/No\n");
214 char *res = fgets(readbuf,
sizeof(readbuf), stdin);
215 if (!res || strchr(
"Nn", readbuf[0]))
230 fprintf(stderr,
"Recursive sis file...\n");
240 "Could not read contained sis file, rc = %d\n", rc);
246 rc = installer.
run(&sisFile, buf2, len,
m_file);
253 "Updated drive to %c from recursive sis file\n",
260 fprintf(stderr,
"Run %.*s during installation/remove\n",
265 fprintf(stderr,
"Running the app will create %.*s\n",
272#define SYSTEMINSTALL "c:\\system\\install\\"
286 while (!files.empty())
290 fprintf(stderr,
"Loading sis file `%s'\n", file.
getName());
304 strcpy(srcName,
"/tmp/plptools-sis-XXXXXX");
305 int fd = mkstemp(srcName);
308 fprintf(stderr,
"Couldn't create temp file: %s\n", strerror(errno));
314 fprintf(stderr,
"Copying from %s to temp file %s\n", name, srcName);
318 off_t fileLen = lseek(fd, 0, SEEK_END);
320 fprintf(stderr,
"Read %d bytes from the Psion file %s\n",
322 lseek(fd, SEEK_SET, 0);
323 uint8_t* sisbuf =
new uint8_t[fileLen];
324 int rc = read(fd, sisbuf, fileLen);
332 fprintf(stderr,
" Ok.\n");
358 fprintf(stderr,
"Removing file component %s.\n", dest);
365 return run(file, buf, len, 0);
382 _(
"You have only one language: %s"),
384 printf(
"%s\n", msgbuf);
389 printf(
"Select a language (%d alternatives):\n", n);
390 for (
int i = 0; i < n; ++i)
403 fprintf(stderr,
"Forcing language to %ld\n", lang);
407 sprintf(msgbuf,
_(
"Installing component: `%s'"), compName);
408 printf(
"%s\n", msgbuf);
423 fprintf(stderr,
"Found %d requisites, of some sort.\n", n);
424 for (
int i = 0; i < n; ++i)
429 " Check if app with uid %08x exists with version >= %d.%d\n",
437 "Checking if this app (uid %08x) exists with a version less than %d.%d.\n",
442 bool uninstallFirst =
false;
451 uninstallFirst =
true;
457 uninstallFirst =
true;
463 uninstallFirst =
true;
477 fprintf(stderr,
"Already installed, but 0?\n");
480 sprintf(msgbuf,
"%s",
_(
"Uninstalling the previous version first."));
481 printf(
"%s\n", msgbuf);
490 fprintf(stderr,
"Found %d files.\n", n);
492 int nCopiedFiles = 0;
494 bool skipnext =
false;
495 bool aborted =
false;
496 while (!aborted && (n-- > 0))
525 "Installed %d files of %d, cutting at offset %u.\n",
529 if (nCopiedFiles == 0)
541 while (compName[namelen] != 0)
543 if (compName[namelen] ==
' ')
547 sprintf(resname,
"C:\\System\\Install\\%.*s.sis", namelen, compName);
549 fprintf(stderr,
"Creating residual sis file %s\n", resname);
559 uint32_t devbits = 0;
565 for (
int i = 0; i < 26; i++)
568 if (((devbits & 1) != 0) &&
572 if ((mediaType == MediaType::kDisk) || (mediaType == MediaType::kRAM))
574 drivelist[ndrives] =
'A' + i;
575 printf(
"%c: %lud bytes free, %lud bytes total\n",
585 drivelist[ndrives] = 0;
590 printf(
"Selecting the only drive %c\n",
m_drive);
592 else if (ndrives == 1)
596 printf(
"Selecting the only drive %c\n",
m_drive);
602 printf(
"Please select a drive\n");
607 if (fgets(readbuf, 2, stdin) == NULL)
609 printf(
"please enter a drive");
613 if ((ch >=
'a' && ch <=
'z') || (ch >=
'A' && ch <=
'Z'))
616 if (!strchr(drivelist,
m_drive))
619 printf(
"Please select a valid drive: %s\n", drivelist);
640 fprintf(stderr,
"Uninstalling %d files, from a total of %d.\n",
671 fprintf(stderr,
"Recursive sis file...\n");
674 uint8_t* buf2 =
m_buf + fileptr;
682 "Could not read contained sis file, rc = %d\n", rc);
688 rc = installer.
run(&sisFile, buf2, len,
m_file);
695 "Updated drive to %c from recursive sis file\n",
A class representing information about a Disk drive on the psion.
MediaType getMediaType() const
Retrieve the media type of the drive.
uint64_t getSpace() const
Retrieve the free capacity on the drive.
uint64_t getSize() const
Retrieve the total capacity of the drive.
Wrapper class featuring range-checking and string representation of enumerated values.
A class, representing a directory entry of the Psion.
const char * getName() const
Retrieve the file name of a directory entry.
Semi smart proxy for communicating with a Psion.
virtual Enum< RFSV::errs > copyToPsion(const char *const from, const char *const to, void *, cpCallback_t func)
virtual Enum< RFSV::errs > dir(const char *dir, PlpDir &files)
virtual Enum< RFSV::errs > copyFromPsion(const char *const from, int fd, cpCallback_t func)
virtual Enum< RFSV::errs > devlist(uint32_t &devbits)
virtual Enum< RFSV::errs > devinfo(const char drive, Drive &plpDrive)
virtual void remove(const char *name)
virtual Enum< RFSV::errs > mkdir(const char *dir)
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