Showing the changes to src/core/util_string.cpp (1 of 26 files). Show all
Unified · Split
| @@ -361,34 +361,35 @@ done: · 360 unmodified lines | |||
| 361 | 361 | ||
| 362 | /* from http://developer.apple.com/library/mac/#qa/qa1549/_index.html */ | 362 | /* from http://developer.apple.com/library/mac/#qa/qa1549/_index.html */ |
| 363 | 363 | ||
| 364 | #ifndef __PLATFORM_WIN32__ | 364 | #if !defined(__PLATFORM_WIN32__) && !defined(__EMSCRIPTEN__) |
| 365 | 365 | ||
| 366 | #include <glob.h> | 366 | #include <glob.h> |
| 367 | 367 | ||
| 368 | //char* CreatePathByExpandingTildePath(const char* path) | ||
| 369 | //{ | ||
| 370 | // glob_t globbuf; | ||
| 371 | // char **v; | ||
| 372 | // char *expandedPath = NULL, *result = NULL; | ||
| 373 | // | ||
| 374 | // assert(path != NULL); | ||
| 375 | // | ||
| 376 | // if (glob(path, GLOB_TILDE, NULL, &globbuf) == 0) //success | ||
| 377 | // { | ||
| 378 | // v = globbuf.gl_pathv; //list of matched pathnames | ||
| 379 | // expandedPath = v[0]; //number of matched pathnames, gl_pathc == 1 | ||
| 380 | // | ||
| 381 | // result = (char*)calloc(1, strlen(expandedPath) + 1); //the extra char is for the null-termination | ||
| 382 | // if(result) | ||
| 383 | // strncpy(result, expandedPath, strlen(expandedPath) + 1); //copy the null-termination as well | ||
| 384 | // | ||
| 385 | // globfree(&globbuf); | ||
| 386 | // } | ||
| 387 | // | ||
| 388 | // return result; | ||
| 389 | //} | ||
| 390 | 368 | ||
| 391 | #endif // __PLATFORM_WIN32__ | 369 | char* CreatePathByExpandingTildePath(const char* path) |
| 370 | { | ||
| 371 | glob_t globbuf; | ||
| 372 | char **v; | ||
| 373 | char *expandedPath = NULL, *result = NULL; | ||
| 374 | |||
| 375 | assert(path != NULL); | ||
| 376 | |||
| 377 | if (glob(path, GLOB_TILDE, NULL, &globbuf) == 0) //success | ||
| 378 | { | ||
| 379 | v = globbuf.gl_pathv; //list of matched pathnames | ||
| 380 | expandedPath = v[0]; //number of matched pathnames, gl_pathc == 1 | ||
| 381 | |||
| 382 | result = (char*)calloc(1, strlen(expandedPath) + 1); //the extra char is for the null-termination | ||
| 383 | if(result) | ||
| 384 | strncpy(result, expandedPath, strlen(expandedPath) + 1); //copy the null-termination as well | ||
| 385 | |||
| 386 | globfree(&globbuf); | ||
| 387 | } | ||
| 388 | |||
| 389 | return result; | ||
| 390 | } | ||
| 391 | |||
| 392 | #endif // __PLATFORM_WIN32__ && __EMSCRIPTEN__ | ||
| 392 | 393 | ||
| 393 | 394 | ||
| 394 | // get full path to file | 395 | // get full path to file |