MCPcopy Index your code
hub / github.com/MapServer/MapServer / msBuildPath

Function msBuildPath

mapstring.c:655–698  ·  view source on GitHub ↗

** Returns a *path* built from abs_path and path. ** The pszReturnPath must be declared by the caller function as an array ** of MS_MAXPATHLEN char */

Source from the content-addressed store, hash-verified

653** of MS_MAXPATHLEN char
654*/
655char *msBuildPath(char *pszReturnPath, const char *abs_path, const char *path)
656{
657 int abslen = 0;
658 int pathlen = 0;
659
660
661 if(path == NULL)
662 {
663 msSetError(MS_IOERR, NULL, "msBuildPath");
664 return NULL;
665 }
666
667 pathlen = strlen(path);
668 if (abs_path)
669 abslen = strlen(abs_path);
670
671 if((pathlen + abslen + 2) > MS_MAXPATHLEN)
672 {
673 msSetError(MS_IOERR, "(%s%s): path is too long", "msBuildPath()",
674 abs_path, path);
675 return NULL;
676 }
677
678 /* Check if path is absolute */
679 if((abs_path == NULL) || (abslen == 0) ||
680 (path[0] == '\\') || (path[0] == '/') ||
681 (pathlen > 1 && (path[1] == ':')))
682 {
683 strlcpy(pszReturnPath, path, MS_MAXPATHLEN);
684 return(pszReturnPath);
685 }
686
687 /* else return abs_path/path */
688 if((abs_path[abslen-1] == '/') || (abs_path[abslen-1] == '\\'))
689 {
690 snprintf(pszReturnPath, MS_MAXPATHLEN, "%s%s", abs_path, path);
691 }
692 else
693 {
694 snprintf(pszReturnPath, MS_MAXPATHLEN, "%s/%s", abs_path, path);
695 }
696
697 return(pszReturnPath);
698}
699
700/*
701** Returns a *path* built from abs_path, path1 and path2.

Callers 15

maplexer.cFile · 0.85
msDrawWMSLayerLowFunction · 0.85
msDrawLegendIconFunction · 0.85
writeLogFunction · 0.85
msBuildPath3Function · 0.85
msTryBuildPathFunction · 0.85
msTileIndexAbsoluteDirFunction · 0.85
msTiledSHPTryOpenFunction · 0.85
msTiledSHPOpenFileFunction · 0.85
msTiledSHPGetShapeFunction · 0.85
msSHPLayerOpenFunction · 0.85
msRasterQueryByRectFunction · 0.85

Calls 2

msSetErrorFunction · 0.85
strlcpyFunction · 0.85

Tested by

no test coverage detected