Back to index

plt-scheme  4.2.1
Functions
Path.cc File Reference
#include "wx.h"
#include <string.h>

Go to the source code of this file.

Functions

char * wxFileNameFromPath (char *path)
char * wxPathOnly (char *path)

Function Documentation

char* wxFileNameFromPath ( char *  path)

Definition at line 31 of file Path.cc.

{
    if (path) {
      int tcp, slen;
      
      tcp = slen = strlen(path);
      while (--tcp >= 0) {
       if (path[tcp] == '/') {
         char *naya;
         tcp++;
         naya = new WXGC_ATOMIC char[slen + 1 - tcp];
         memcpy(naya, path + tcp, slen + 1 - tcp);
         return naya;
       }
      }
    }

    return path;
}

Here is the caller graph for this function:

char* wxPathOnly ( char *  path)

Definition at line 51 of file Path.cc.

{
  if (path) {
    int p, last_slash = 0;
    char *buf;

    buf = new WXGC_ATOMIC char[strlen(path) + 1];
    
    // copy path and keep the last slash or baskslash in mind
    for (p = 0; path[p]; p++) {
      buf[p] = path[p];
      if (buf[p] == '/')
       last_slash = p;
    }
    if (last_slash) {
      buf[last_slash] = 0;
      return buf;
    }
  }

  return NULL;
}