lib/filePath.c File Reference

#include "common.h"
#include "filePath.h"

Include dependency graph for filePath.c:

Go to the source code of this file.

Functions

void undosPath (char *path)
void splitPath (char *path, char dir[256], char name[128], char extension[64])
static char * findSlashBefore (char *start, char *e)
char * expandRelativePath (char *baseDir, char *relPath)


Function Documentation

char* expandRelativePath ( char *  baseDir,
char *  relPath 
)

Definition at line 65 of file filePath.c.

References cloneString(), countChars(), findSlashBefore(), needMem(), startsWith(), undosPath(), and warn().

Referenced by htmlExpandUrl().

00067 {
00068 char *e = baseDir + strlen(baseDir);
00069 int slashCount;
00070 char *rel = relPath;
00071 char *result;
00072 int size, baseSize;
00073 undosPath(baseDir);
00074 undosPath(relPath);
00075 slashCount = countChars(baseDir, '/');
00076 if (baseDir[0] == 0)
00077     slashCount = -1;
00078 while (startsWith("../", rel))
00079     {
00080     if (slashCount < 0)
00081         {
00082         warn("More ..'s in \"%s\" than directories in \"%s\"", relPath, baseDir);
00083         return NULL;
00084         }
00085     else if (slashCount == 0)
00086         e = baseDir;
00087     else
00088         e = findSlashBefore(baseDir, e);
00089     slashCount -= 1;
00090     rel += 3;
00091     }
00092 baseSize = e - baseDir;
00093 size = strlen(rel) + 1;
00094 if (baseSize > 0)
00095     size += baseSize + 1;
00096 if (baseSize > 0)
00097     {
00098     result = needMem(size);
00099     memcpy(result, baseDir, baseSize);
00100     result[baseSize] = '/';
00101     strcpy(result + baseSize + 1, rel);
00102     }
00103 else
00104     result = cloneString(rel);
00105 return result;
00106 }

Here is the call graph for this function:

Here is the caller graph for this function:

static char* findSlashBefore ( char *  start,
char *  e 
) [static]

Definition at line 54 of file filePath.c.

Referenced by expandRelativePath().

00056 {
00057 while (--e >= start)
00058     {
00059     if (*e == '/')
00060          return e;
00061     }
00062 return start;
00063 }

Here is the caller graph for this function:

void splitPath ( char *  path,
char  dir[256],
char  name[128],
char  extension[64] 
)

Definition at line 11 of file filePath.c.

References errAbort(), and undosPath().

00016 {
00017 char *dirStart, *nameStart, *extStart, *extEnd;
00018 int dirSize, nameSize, extSize;
00019 
00020 undosPath(path);
00021 dirStart = path;
00022 nameStart = strrchr(path,'/');
00023 if (nameStart == NULL)
00024     nameStart = path;
00025 else
00026     nameStart += 1;
00027 extStart = strrchr(nameStart, '.');
00028 if (extStart == NULL)
00029     extStart = nameStart + strlen(nameStart);
00030 extEnd = extStart + strlen(extStart);
00031 if ((dirSize = (nameStart - dirStart)) >= 256)
00032     errAbort("Directory too long in %s", path);
00033 if ((nameSize = (extStart - nameStart)) >= 128)
00034     errAbort("Name too long in %s", path);
00035 if ((extSize = (extEnd - extStart)) >= 64)
00036     errAbort("Extension too long in %s", path);
00037 if (dir != NULL)
00038     {
00039     memcpy(dir, dirStart, dirSize);
00040     dir[dirSize] = 0;
00041     }
00042 if (name != NULL)
00043     {
00044     memcpy(name, nameStart, nameSize);
00045     name[nameSize] = 0;
00046     }
00047 if (extension != NULL)
00048     {
00049     memcpy(extension, extStart, extSize);
00050     extension[extSize] = 0;
00051     }
00052 }

Here is the call graph for this function:

void undosPath ( char *  path  ) 

Definition at line 5 of file filePath.c.

References subChar().

Referenced by expandRelativePath(), and splitPath().

00007 {
00008 subChar(path, '\\', '/');
00009 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Dec 25 19:50:10 2007 for blat by  doxygen 1.5.2