Skip to content

Commit 174c20d

Browse files
feat: added cd command to change between directories
1 parent 64dc336 commit 174c20d

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

headers/commands.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ int quickoverflow_search(char **args); //open search
2626
int quickoverflow_help(char **args); //help command
2727
int quickoverflow_quit(char **args); //exit command
2828
int quickoverflow_about(char **args); //about command
29+
int quickoverflow_cd(char **args);
2930

3031
/*
3132
List of builtin commands, followed by their corresponding functions.
@@ -35,13 +36,15 @@ char *builtin_str[] = {
3536
"help", //help command
3637
"quit", //exit command
3738
"about",
39+
"cd",
3840
};
3941

4042
int (*builtin_func[]) (char **) = {
4143
&quickoverflow_search, //search directory
4244
&quickoverflow_help, //help command
4345
&quickoverflow_quit, //exit command
44-
&quickoverflow_about,
46+
&quickoverflow_about, //about
47+
&quickoverflow_cd, //change dir
4548
};
4649

4750
int quickoverflow_num_builtins() {
@@ -52,6 +55,21 @@ int quickoverflow_num_builtins() {
5255
***********************************Builtin function implementations*************************************
5356
*/
5457

58+
//Update 2.0.0 - Added cd for directory traversal
59+
60+
//***************************************chdir*********************************************** */
61+
int quickoverflow_cd(char **args)
62+
{
63+
if (args[1] == NULL) {
64+
fprintf(stderr, "QuickOverflow : expected argument to \"cd\"\n");
65+
} else {
66+
if (chdir(args[1]) != 0) {
67+
perror("QuickOverflow");
68+
}
69+
}
70+
return 1;
71+
}
72+
5573
//***************************************sofsearch*********************************************** */
5674
//function for calling the python files for searching
5775
int quickoverflow_search(char **args)
@@ -72,7 +90,7 @@ int quickoverflow_search(char **args)
7290
PyRun_SimpleFile(fp, "search.py");
7391
fclose(fp);
7492

75-
//Update 1.1.0 removed Py_Finalise to avoid segmentation faults
93+
//Update 2.0.0 removed Py_Finalise to avoid segmentation faults
7694

7795
return 1;
7896
}
@@ -84,7 +102,7 @@ int quickoverflow_search(char **args)
84102
int quickoverflow_help(char **args){
85103
int i;
86104
printf("--------------------------------QuickOverflow-----------------------------\n");
87-
printf("---------------------------------Version 1.0.1----------------------------\n");
105+
printf("---------------------------------Version 2.0.0----------------------------\n");
88106
printf("Type program names and arguments, and hit enter.\n");
89107
printf("The following are built in:\n");
90108

@@ -105,8 +123,8 @@ int quickoverflow_quit(char **args){
105123

106124
int quickoverflow_about(char **args){
107125
printf("-------------------------------QuickOverflow-----------------------------------\n");
108-
printf("Version: 1.0.1\n");
109-
printf("License: MIT License\n");
126+
printf("Version: 2.0.0\n");
127+
printf("License: GNU GPL-3 License\n");
110128
printf("Author: Aryan Karamtoth (SpaciousCoder78)\n");
111129
printf("Author Email: [email protected]\n");
112130
printf("Supported Operating Systems: Linux\n");

install.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ pip3 install -r requirements.txt --break-system-packages
55
mkdir -p bin
66
gcc -I/usr/include/python3.12 main.c -lpython3.12 -o bin/QuickOverflow
77

8+
#read -p "Enter the download path of the source: " $DLPATH
89

10+
#echo "You mentioned $DLPATH as your app source"
11+
12+
#chmod +x search.py
13+
14+
#cd $HOME && mkdir bin
15+
16+
#mv "$DLPATH" "$HOME/bin/"
17+
18+
#export PATH="$HOME/bin:$PATH"
919

1020

0 commit comments

Comments
 (0)