/[ascend]/trunk/base/generic/general/ospath.c
ViewVC logotype

Diff of /trunk/base/generic/general/ospath.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 588 by johnpye, Thu May 11 02:06:46 2006 UTC revision 589 by johnpye, Thu May 11 03:10:43 2006 UTC
# Line 373  void ospath_cleanup(struct FilePath *fp) Line 373  void ospath_cleanup(struct FilePath *fp)
373          //M("NEXT TOKEN");          //M("NEXT TOKEN");
374          //X(p);          //X(p);
375          //X(path+strlen(p)+1);          //X(path+strlen(p)+1);
376          if(*p=='$'){          if(strcmp(p, "~")==0){
             M("PATH COMPONENT WITH ENV VAR");  
   
         }else if(strcmp(p, "~")==0){  
377    
378              if(p == path){ // check that the ~ is the first character in the path              if(p == path){ // check that the ~ is the first character in the path
379                  if(ospath_isvalid(home)){                  if(ospath_isvalid(home)){
# Line 457  int ospath_isvalid(struct FilePath *fp){ Line 454  int ospath_isvalid(struct FilePath *fp){
454  char *ospath_str(struct FilePath *fp){  char *ospath_str(struct FilePath *fp){
455      char *s;      char *s;
456  #ifdef WINPATHS  #ifdef WINPATHS
457      s = (char *)MALLOC(sizeof(char)*(strlen(fp->drive)+strlen(fp->path) ) );      s = (char *)MALLOC(sizeof(char)*(strlen(fp->drive)+strlen(fp->path) +1) );
458      STRCPY(s,fp->drive);      STRCPY(s,fp->drive);
459      STRCAT(s,fp->path);      STRCAT(s,fp->path);
460  #else  #else
461      s = MALLOC(sizeof(char)*strlen(fp->path));      s = MALLOC(sizeof(char)*(strlen(fp->path)+1));
462      STRCPY(s,fp->path);      STRCPY(s,fp->path);
463  #endif  #endif
464      return s;      return s;
# Line 513  struct FilePath *ospath_getparent(struct Line 510  struct FilePath *ospath_getparent(struct
510      char *pos;      char *pos;
511      int len1;      int len1;
512      char sub[PATH_MAX];      char sub[PATH_MAX];
513      struct FilePath *fp1;      struct FilePath *fp1, *fp2;
514    
515      D(fp);      D(fp);
516    
517      if(strlen(fp->path) == 0 || ospath_isroot(fp))      if(strlen(fp->path) == 0){
518      {          fp1 = ospath_getcwd();
519          // return empty path.          fp2 = ospath_getparent(fp1);
520          return ospath_new("");          ospath_free(fp1);
521            return fp2;
522        }else if(ospath_isroot(fp)){
523            // stay at root
524            return ospath_new("/");
525      }      }
526    
527      // reverse find a / ignoring the end / if it exists.      // reverse find a / ignoring the end / if it exists.
# Line 891  struct FilePath *ospath_concat(struct Fi Line 892  struct FilePath *ospath_concat(struct Fi
892    
893      fp = (struct FilePath *)MALLOC(sizeof(struct FilePath));      fp = (struct FilePath *)MALLOC(sizeof(struct FilePath));
894    
     D(fp1);  
     D(fp2);  
   
895      if(!ospath_isvalid(fp1)){      if(!ospath_isvalid(fp1)){
896          if(ospath_isvalid(fp2)){          if(ospath_isvalid(fp2)){
897              ospath_copy(fp,fp2);              ospath_copy(fp,fp2);

Legend:
Removed from v.588  
changed lines
  Added in v.589

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22