inline static std::string abs_path(const char* srcpath) { std::string strAbsolutionpath = ""; char abspath[MAX_BUFFER] = {0}; #ifdef _WIN32 if(_fullpath(abspath, srcpath, MAX_BUFFER) != NULL) { if(strstr(srcpath, abspath)) strAbsolutionpath.append(srcpath); else strAbsolutionpath.append(abspath, strlen(abspath)); } else { printf("invalid path!\n"); } #else if(getcwd(abspath, MAX_BUFFER) != NULL) { char *pszfull = (char*)malloc(MAX_BUFFER*sizeof(char*)); memcpy(pszfull, abspath, strlen(abspath)); if(pszfull[0] == '/') strAbsolutionpath.append(srcpath); else { strcat(pszfull, srcpath); strAbsolutionpath.append(pszfull).append("/").append(srcpath); } if(pszfull) free(pszfull); } else { printf("invailed path!\n"); } #endif return strAbsolutionpath; }