fixed installation errors making it impossible to read some files on linux

master
Chiatiah Calson 5 years ago
parent 7fdc19f688
commit 47c0825125

@ -14,6 +14,7 @@ Program Size: 2.8MB
#include<string.h>
#include<time.h>
#include<ctype.h>
#include <unistd.h>
//cmdtypist.c: Implementing the main
#include"functions_for_cmd_typist.h"//function prototypes and global variables.
@ -26,6 +27,7 @@ Program Size: 2.8MB
char argv[5][18];
int main(int argc, char **argv)//argc=command line counter, argv=pointer to pointer to character(command line arguments)
{
redirect();
lmt_pg_size();
name_display();
read_message_conf();//welcome message for first time users.

Binary file not shown.

@ -415,6 +415,48 @@ extern void lmt_pg_size()//limit page size
rewind(fp);
}
}
if(fclose(fp)){
fprintf(stderr, "%s\n", "Fatal Error, Unable to close some files\n");
exit(EXIT_FAILURE);
}
}
/**
* @param void
* performs a test to make sure cmdtypist has been installed to home directory
* installed? true: it changes the current directory the the home/cmdTypist directory
* false: it gives a warning message with possible fixes and continues
*/
extern void redirect(void)
{
char idir[62] = "";
if(getenv("HOME") != NULL)
{
strncpy(idir,getenv("HOME"), 50);
strcat(idir, "/cmdTypist");//installation directory
printf("%s\n", idir);
}
// exit(0);
FILE *fp;
//call script that verifies if program is installed to $home/cmdTypist
char test_dir[60] = "";
strncpy(test_dir, idir, 50);
strcat(test_dir, "/files.h");
if((fp=fopen(test_dir,"r")) == NULL)
{
fprintf(stderr, "%s\n", "Program not installed to $HOME/cmdTypist directory\n");
fprintf(stderr, "\t- %s\n", "Navigate to cmdtypist directory manually, before running it\n");
fprintf(stderr, "\t- %s\n", "OR uninstall and reinstall a fresh copy\n");
return;
}else{
//system(idir); //navigate to installation directory
//change directory
if(chdir(idir) == -1){
fprintf(stderr, "%s\n", "Error changing directory to $HOME/cmdTypist");
exit(EXIT_FAILURE);
}
}
if(fclose(fp)){
fprintf(stderr, "%s\n", "Fatal Error, Unable to close some files\n");
exit(EXIT_FAILURE);

@ -1,10 +1,10 @@
#!/bin/bash
#install cmdtypist
gcc ../cmd_typist.c -o ../cmd_typist &&
gcc ../cmd_typist.c -o ../cmdtypist &&
sudo cp ../cmdtypist /usr/bin/cmdtypist &&
mkdir $HOME/cmdTypist &&
cp -r ../ $HOME/cmdTypist/ &&
sudo cp ../cmdtypist /usr/bin/cmdtypist &&
mkdir $HOME/cmdtypist &&
cp -r ../ $HOME/cmdtypist/ &&
sudo cp ../cmdtypist /usr/bin/ &&
sudo chmod +x /usr/bin/cmdtypist &&
(echo "CMDTYPIST successfully compiled and installed, learn how to use cmdtypist commands by running 'cmdtypist --help'"; exit 0) ||
(c=$?; echo "CMDTYPIST was unable to install: "; (exit $c))

@ -1,6 +1,6 @@
#!/bin/bash
#remove cmdtypist and associated files.
sudo rm /usr/bin/cmdtypist &&
sudo rm -r $HOME/cmdtypist &&
sudo rm -r $HOME/cmdTypist &&
echo "cmdtypist uninstalled" ||
echo "unable to install cmdtypist"; exit $?
echo "unable to uninstall cmdtypist"; exit $?

Loading…
Cancel
Save