#include #include #include #ifdef UNIX #include #endif #include "aplinks.h" int set_sdir_sfile(char *argv, char *sdir, char *sfile) { DIR *dirp; char *filetop; int i; #if 0 #ifdef UNIX char real_sdir[MAXPATHLEN]; char real_homedir[MAXPATHLEN]; char *homedir; int len, len1, len2; #endif #endif if((dirp = opendir(argv)) == NULL){ /* argv is file */ if((filetop = strrchr(argv, DIR_DELIM)) == NULL){ strcpy(sfile, argv); strcpy(sdir, ""); } else{ filetop++; strcpy(sfile, filetop); filetop--; for(i = 0; i < strlen(argv); i++){ if((argv + i) == filetop){ *(sdir + i) = '\0'; break; } *(sdir + i) = *(argv + i); } } } else{ /* argv is dir */ closedir(dirp); strcpy(sdir, argv); strcpy(sfile, "*.*"); } #ifdef UNIX #if 0 realpath(sdir, real_sdir); homedir = getenv("HOME"); realpath(homedir, real_homedir); len = ((len1 = strlen(real_homedir)) < (len2 = strlen(real_sdir))) ? len1 : len2; if(strncmp(real_sdir, real_homedir, len) == 0){ strcpy(sdir, &real_sdir[len + 1]); } #endif if(*(sdir + (strlen(sdir) - 1)) == DIR_DELIM){ *(sdir + (strlen(sdir) - 1)) = '\0'; } #endif return 0; }