mirror of
https://gitlab.com/klmp200/fish.git
synced 2024-11-14 04:43:20 +00:00
Merge branch 'bro' into 'master'
Please dont be invaliiiiiiid, yeah-eah See merge request !12
This commit is contained in:
commit
e6aaeaf830
@ -38,6 +38,7 @@ WordList * fishExpand(WordList *wordList) {
|
||||
|
||||
tempElement = tempElement->next;
|
||||
|
||||
|
||||
}
|
||||
|
||||
freeWordList(wordList);
|
||||
@ -122,14 +123,20 @@ void recursiveExpandWord(char* path, WordList* listToExpand){
|
||||
|
||||
tempElement = foundFiles->first;
|
||||
char* concatenedEndOfPath = concatWordListToWord(pathToList, indexToExpand, pathToList->size - 1);
|
||||
int isDir;
|
||||
|
||||
for(i=0; i < foundFiles->size; i++){
|
||||
|
||||
tmpWord = tempElement->word;
|
||||
|
||||
isDir = isDirectory(tmpWord);
|
||||
|
||||
tempElement->word = trueStrcat(tempElement->word, concatenedEndOfPath);
|
||||
free(tmpWord);
|
||||
tmpWord = NULL;
|
||||
recursiveExpandWord(tempElement->word, listToExpand);
|
||||
if(isDir){
|
||||
recursiveExpandWord(tempElement->word, listToExpand);
|
||||
}
|
||||
|
||||
tempElement = tempElement->next;
|
||||
|
||||
@ -153,7 +160,7 @@ char* concatWordListToWord(WordList* list,int firstElemIndex, int lastElemIndex)
|
||||
|
||||
int i;
|
||||
char* concatenedString = (char*) malloc(sizeof(char));
|
||||
char* tmpConcatenedString = concatenedString;
|
||||
char* tmpConcatenedString = NULL;
|
||||
if(concatenedString == NULL) crash();
|
||||
concatenedString[0] = '\0';
|
||||
|
||||
@ -174,6 +181,7 @@ char* concatWordListToWord(WordList* list,int firstElemIndex, int lastElemIndex)
|
||||
}
|
||||
for(i=firstElemIndex; i < lastElemIndex; i++){
|
||||
|
||||
tmpConcatenedString = concatenedString;
|
||||
concatenedString = trueStrcat(concatenedString, tempElement->word);
|
||||
free(tmpConcatenedString);
|
||||
tempElement = tempElement->next;
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <pcre.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include "fish_utils.h"
|
||||
#include "fish_types.h"
|
||||
|
||||
@ -343,3 +345,22 @@ char* trueStrcat(char* string1, char* string2){
|
||||
return newString;
|
||||
|
||||
}
|
||||
|
||||
int isDirectory(char* path){
|
||||
|
||||
DIR* directory = opendir(path);
|
||||
|
||||
//printf("testing %s\n", path);
|
||||
|
||||
if(directory != NULL){
|
||||
closedir(directory);
|
||||
return 1;
|
||||
}
|
||||
else if(errno == ENOTDIR){
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "fish : Warning : %s is an invalid path you stupid human\n", path);
|
||||
return 0; //hihi
|
||||
}
|
||||
}
|
||||
|
@ -43,5 +43,7 @@ int stringContains(char* string, char charToTest);
|
||||
|
||||
char* trueStrcat(char* string1, char* string2);
|
||||
|
||||
int isDirectory(char* path);
|
||||
|
||||
|
||||
#endif //FISH_FISH_UTILS_H
|
||||
|
Loading…
Reference in New Issue
Block a user