MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlParserGetDirectory

Function xmlParserGetDirectory

ThirdParty/libxml2/vtklibxml2/xmlIO.c:2892–2922  ·  view source on GitHub ↗

* xmlParserGetDirectory: * @filename: the path to a file * * lookup the directory for that file * * Returns a new allocated string containing the directory, or NULL. */

Source from the content-addressed store, hash-verified

2890 * Returns a new allocated string containing the directory, or NULL.
2891 */
2892char *
2893xmlParserGetDirectory(const char *filename) {
2894 char *ret = NULL;
2895 char dir[1024];
2896 char *cur;
2897
2898 if (filename == NULL) return(NULL);
2899
2900#if defined(_WIN32)
2901# define IS_XMLPGD_SEP(ch) ((ch=='/')||(ch=='\\'))
2902#else
2903# define IS_XMLPGD_SEP(ch) (ch=='/')
2904#endif
2905
2906 strncpy(dir, filename, 1023);
2907 dir[1023] = 0;
2908 cur = &dir[strlen(dir)];
2909 while (cur > dir) {
2910 if (IS_XMLPGD_SEP(*cur)) break;
2911 cur --;
2912 }
2913 if (IS_XMLPGD_SEP(*cur)) {
2914 if (cur == dir) dir[1] = 0;
2915 else *cur = 0;
2916 ret = xmlMemStrdup(dir);
2917 } else {
2918 ret = xmlMemStrdup(".");
2919 }
2920 return(ret);
2921#undef IS_XMLPGD_SEP
2922}
2923
2924/**
2925 * xmlNoNetExists:

Callers 1

inputPushFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected