/*------------------------------------------------------------------- xfilespec(string,opt) opt: D c:\testpath\name.ext = 'c' E c:\testpath\name.ext = 'ext' F same as spfservice("query,"FILESPEC") P c:\testpath\name.ext = '\testpath\' L c:\testpath\name.ext = ':\testpath\name.ext' M c:\testpath\name.ext = 'name.ext' N c:\testpath\name.ext = 'name' DPN c:\testpath\name.ext = 'c:\testpath\name' DP c:\testpath\name.ext = 'c:\testpath\' S c:\testpath\name.ext = 'c \testpath\ name ext' -------------------------------------------------------------------*/ char *xfilespec(char *x, char *xopt){ char *xret =""; char *xfilespec; char *xdrv; char *xext =""; char *xpath = ""; char *xname = ""; //File name without ext char *xmbr = ""; //File name with ext int xlen; int xsp; int xep; int xlth; char *xt; xlen = strlen(x); //Get Drive Letter----------------- xdrv = strgetsubstr(x,1,1); //Get Filespec Exnt---------------- xsp = strfindlast(x,"."); if(xsp > 0){ xsp++; xlth = xlen - xsp +1; xext = strgetsubstr(x,xsp,xlth); }//endif //Get Path------------------------- xsp = strfindsubstr(x,"\\",1); xep = strfindlast(x,"\\"); if(xsp > 0){ xlth = xep - xsp + 1; xpath = strgetsubstr(x,xsp,xlth); }//endif //Get File name(no ext)------------ xsp = xep + 1; xep = strfindlast(x,"."); if(xep ==0) xep = xlen; xlth = xep - xsp + 1; xname = strgetsubstr(x,xsp,xlth); xlth = strlen(xname); xt = strgetsubstr(xname,xlth,1); if(xt == "."){ xlth = xlth -1; xname = strgetsubstr(xname,1,xlth); }//endif //Get Member (with ext)------------ xlth = xlen - xsp + 1; xmbr = strgetsubstr(x,xsp,xlth); xlth = strlen(xmbr); //Return Option-------------------- if(xopt == "L"){ xlth = xlen - 1; xret = strgetsubstr(x,2,xlth); } if(xopt == "F"){xret = spfservice("query","FILESPEC");} if(xopt == "D"){xret = strgetsubstr(x,1,1);} if(xopt == "E"){strcpy(xret,xext);} if(xopt == "M"){strcpy(xret,xmbr);} if(xopt == "N"){strcpy(xret,xname);} if(xopt == "P"){strcpy(xret,xpath);} if(xopt == "DPN"){xret = strcompose(strgetsubstr(x,1,1),":",xpath,xname);} if(xopt == "DP"){xret = strcompose(strgetsubstr(x,1,1),":",xpath);} if(xopt == "S"){xret = strcompose(strgetsubstr(x,1,1)," ",xpath," ",xname," ",xext);} return (xret); }//xfilespec