WORD get_file(WORD label) { WORD butn, ii; BYTE tmp_path[64], tmp_name[13]; if ( !sav_rcspath[0] ) get_defpath(tmp_path, "*.RSC"); else strcpy(tmp_path, sav_rcspath); tmp_name[0] = '\0'; #if GEMDOS if (Sversion() >= 0x0140) { LONG fs_label; fs_label = string_addr(label); fsel_exinput(ADDR(&tmp_path[0]), ADDR(&tmp_name[0]), &butn, (BYTE FAR *)fs_label); } else #endif fsel_input(ADDR(&tmp_path[0]), ADDR(&tmp_name[0]), &butn); graf_mouse(rcs_mform, 0x0L); if (butn) { if (!tmp_name[0]) if (hndl_alert(1, string_addr(NOFNAME)) == 1) return(FALSE); if (strcmp(sav_rcspath, tmp_path)) { #if GEMDOS Dsetpath((const char *)ADDR(tmp_path)); #else dos_chdir(ADDR(tmp_path)); #endif strcpy(sav_rcspath, tmp_path); } strcpy(rcs_rfile, &tmp_path[0]); for (ii = 0; rcs_rfile[ii] && rcs_rfile[ii] != '*'; ii++) ; rcs_rfile[ii - 1] = NULL; /* knock off slash */ strcat(rcs_rfile, "\\"); strcpy(&rsc_path[1], rcs_rfile); rsc_path[0] = strlen(rcs_rfile); strcat(rcs_rfile, &tmp_name[0]); /* Force 'rsc' extension on resource file.*/ r_to_xfile(rcs_rfile, "RSC"); r_to_xfile(rcs_dfile, "DFN"); return (TRUE); } /* if butn */ else return (FALSE); } /* get_file */
void sh_chdef(SHELL *psh) { /* if we should exec */ /* the default command*/ /* then let it be */ /* known that it is */ /* a gem appl. */ psh->sh_isdef = FALSE; if ( psh->sh_dodef ) { psh->sh_isdef = psh->sh_isgem = TRUE; psh->sh_fullstep = 0; if(psh->sh_cdir[1] == ':') dos_sdrv(psh->sh_cdir[0] - 'A'); dos_chdir((BYTE *)ADDR(&psh->sh_cdir[0])); strcpy(&D.s_cmd[0], &psh->sh_desk[0]); } else { if(sh_apdir[1] == ':') dos_sdrv(sh_apdir[0] - 'A'); /* desktop's def. dir */ dos_chdir(sh_apdir); } }
int dos_ChDir(char *path) { int res; static pstring LastDir=""; if (strcsequal(path,".")) return(0); if (*path == '/' && strcsequal(LastDir,path)) return(0); DEBUG(3,("dos_ChDir to %s\n",path)); res = dos_chdir(path); if (!res) pstrcpy(LastDir,path); return(res); }
static void sh_init(void) { WORD cnt, need_ext; BYTE *psrc, *pdst, *pend; BYTE *s_tail; SHELL *psh; BYTE savch; psh = &sh[0]; sh_deskf(2, (LONG)&ad_pfile); /* add in internal */ /* search paths with */ /* right drive letter */ sh_addpath(); /* set defaults */ psh->sh_doexec = psh->sh_dodef = gl_shgem = psh->sh_isgem = TRUE; psh->sh_fullstep = FALSE; /* parse command tail */ /* that was stored in */ /* geminit */ psrc = s_tail = &D.g_dir[0]; /* reuse part of globals*/ memcpy(s_tail,ad_stail,128); cnt = *psrc++; if (cnt) { /* null-terminate it */ pend = psrc + cnt; *pend = NULL; /* scan off leading */ /* spaces */ while( (*psrc) && (*psrc == ' ') ) psrc++; /* if only white space */ /* get out don't */ /* bother parsing */ if (*psrc) { pdst = psrc; while ( (*pdst) && (*pdst != ' ') ) pdst++; /* find end of app name */ /* save command to do */ /* instead of desktop */ savch = *pdst; *pdst = '\0'; /* mark for sh_name() */ pend = sh_name(psrc); /* see if path also */ *pdst = savch; /* either blank or null */ pdst = &D.s_cmd[0]; if (pend != psrc) { if (*(psrc+1) != ':') /* need drive */ { *pdst++ = gl_logdrv; /* current drive */ *pdst++ = ':'; if (*psrc != '\\') *pdst++ = '\\'; } while (psrc < pend) /* copy rest of path */ *pdst++ = *psrc++; if (*(pdst-1) == '\\') /* back up one char */ pdst--; *pdst = '\0'; pend = &D.s_cmd[0]; while (*pend) /* upcase the path */ { *pend = toupper(*pend); pend++; } dos_sdrv(D.s_cmd[0] -'A'); dos_chdir(D.s_cmd); *pdst++ = '\\'; } need_ext = TRUE; while ( (*psrc) && (*psrc != ' ') ) { if (*psrc == '.') need_ext = FALSE; *pdst++ = *psrc++; } /* append .APP if no */ /* extension given */ if (need_ext) strcpy(pdst, ".APP"); else *pdst = NULL; pdst = &D.s_cmd[0]; while (*pdst) /* upcase the command */ { *pdst = toupper(*pdst); pdst++; } psh->sh_dodef = FALSE; /* save the remainder */ /* into command tail */ /* for the application*/ pdst = &s_tail[1]; /* if ( (*psrc) && * if tail then take * (*psrc != 0x0D) && * out first space * (*psrc == ' ') ) psrc++; */ if (*psrc == ' ') psrc++; /* the batch file allows */ /* three arguments */ /* one for a gem app */ /* and 2 for arguments */ /* to the gem app. */ /* if there are < three */ /* there will be a space */ /* at the end of the last*/ /* arg followed by a 0D */ while ( (*psrc) && (*psrc != 0x0D) && (*psrc != 0x09) && /* what is this?? */ !((*psrc == '/') && (toupper(*(psrc+1)) == 'D')) ) { if ( (*psrc == ' ') && ( (*(psrc+1) == 0x0D) || (*(psrc+1) == NULL)) ) psrc++; else *pdst++ = toupper(*psrc++); } *pdst = NULL; s_tail[0] = strlen(&s_tail[1]); /* don't do the desktop */ /* after this command */ /* unless a /d was */ /* encounterd */ psh->sh_doexec = (toupper(*(psrc+1)) == 'D'); } } LBCOPY(ad_stail, (LONG)(&s_tail[0]), 128); }