diff options
-rw-r--r-- | draw.c | 32 | ||||
-rw-r--r-- | read_cfg.c | 19 | ||||
-rw-r--r-- | read_cfg.h | 2 | ||||
-rw-r--r-- | read_cfg.o | bin | 6672 -> 7088 bytes |
4 files changed, 51 insertions, 2 deletions
@@ -17,6 +17,7 @@ void update_entries(); void switch_col(); void trav_col(int dir); //0 = down, 1 = up void launch_entry(); +char *compat_convert(char *path, int mode); static int width; static int height; @@ -263,16 +264,17 @@ void trav_col(int dir){ return; } -//TODO add ability to use arguments with launcher programs (like -f for fullscreen and such) void launch_entry(){ char *program = get_gprog(g[g_hover]); char *flags = get_gflags(g[g_hover]); char *path = get_epath(e[e_hover]); + int mode = get_compmode(); //if the entry is an executable file (doesn't have a launcher) if(!(strcmp(program, "./"))) system(path); else{ + if(mode != 0) path = compat_convert(path, mode); strcat(program, " \""); if(flags[0] !='\0'){ strcat(program, flags); @@ -286,3 +288,31 @@ void launch_entry(){ return; } + +char *compat_convert(char *path, int mode){ + char *new = malloc(sizeof(char) * BUF_LEN); + char *trav = new; + + //1 -> WSL: letter is in /mnt/, convert slashes to backslashes + if(mode == 1){ + path = path+5; + *trav = *path - 32; //point at letter, make it uppercase + trav++; + *trav = ':'; + path++; + trav++; + + //convert each character + while(*path != '\0'){ + if(*path == '/') *trav = '\\'; + else *trav = *path; + path++; + trav++; + } + *trav = '\0'; + } + + else printf("Error: mode should not be %d\n", mode); + + return new; +} @@ -14,12 +14,19 @@ //public void cfg_interp(); void check_line(char *buffer); +int get_compmode(); //private void handle_fname(char *path, char *group); int search_ch(char *str, char c); int wild_cmp(char *wild, char *literal); +//allow for compatability with compatability layers such as WSL +int compmode = 0; +//0 -> none +//1 -> WSL +//maybe more later? + void cfg_interp(){ FILE *fp; char buffer[BUF_LEN]; @@ -96,7 +103,6 @@ void check_line(char *buffer){ //add entry(ies) to a group: first arg is the file(s), second arg is the group to add to //TODO add potential dash functions - //TODO account for spaces in file name //TODO add support for "-R" recursive adding //TODO add sorting functionality if(!(strcmp(args[0], "add"))) handle_fname(args[1], args[2]); @@ -104,6 +110,13 @@ void check_line(char *buffer){ //create a new group else if(!(strcmp(args[0], "addGroup"))) group_add(args[1], NULL); + //set compatability mode + else if(!(strcmp(args[0], "compMode"))){ + if(!(strcmp(args[1], "WSL"))) compmode = 1; + else printf("Error: Unknown Compatability Mode Argument \"%s\"\n", args[1]); + } + + //TODO fix this so it can give an error that it doesn't recognize args[0] else{ //remaining possibilities involve args[1] being a char* referring to a group g = get_groups(); @@ -131,6 +144,10 @@ void check_line(char *buffer){ return; } +int get_compmode(){ + return compmode; +} + void handle_fname(char *path, char *group){ ENTRY *new; char *search; //pointer for traversing path @@ -5,4 +5,6 @@ void cfg_interp(); void check_line(char *buffer); +int get_compmode(); + #endif Binary files differ |