MCPcopy Create free account
hub / github.com/ZDoom/Raze / NicePath

Function NicePath

source/common/utility/cmdlib.cpp:894–941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

892//==========================================================================
893
894FString NicePath(const char *path)
895{
896#ifdef _WIN32
897 if (*path == '\0')
898 {
899 return FString(".");
900 }
901 return ExpandEnvVars(path);
902#else
903 if (path == NULL || *path == '\0')
904 {
905 return FString("");
906 }
907 if (*path != '~')
908 {
909 return ExpandEnvVars(path);
910 }
911
912 passwd *pwstruct;
913 const char *slash;
914
915 if (path[1] == '/' || path[1] == '\0')
916 { // Get my home directory
917 pwstruct = getpwuid(getuid());
918 slash = path + 1;
919 }
920 else
921 { // Get somebody else's home directory
922 slash = strchr(path, '/');
923 if (slash == NULL)
924 {
925 slash = path + strlen(path);
926 }
927 FString who(path, slash - path);
928 pwstruct = getpwnam(who.GetChars());
929 }
930 if (pwstruct == NULL)
931 {
932 return ExpandEnvVars(path);
933 }
934 FString where(pwstruct->pw_dir);
935 if (*slash != '\0')
936 {
937 where += ExpandEnvVars(slash);
938 }
939 return where;
940#endif
941}
942
943
944//==========================================================================

Callers 14

CollectSearchPathsFunction · 0.85
SaveScreenshotFunction · 0.85
UNSAFE_CCMDFunction · 0.85
BaseFileSearchFunction · 0.85
mus_NicePathFunction · 0.85
CollectSoundfontsMethod · 0.85
G_GetSavegamesFolderFunction · 0.85
G_BuildSaveNameFunction · 0.85
GetUserFileFunction · 0.85
M_GetAppDataPathFunction · 0.85
M_GetCachePathFunction · 0.85
M_GetScreenshotsPathFunction · 0.85

Calls 3

ExpandEnvVarsFunction · 0.85
FStringClass · 0.70
GetCharsMethod · 0.45

Tested by 6

GetUserFileFunction · 0.68
M_GetAppDataPathFunction · 0.68
M_GetCachePathFunction · 0.68
M_GetScreenshotsPathFunction · 0.68
M_GetSavegamesPathFunction · 0.68
M_GetDocumentsPathFunction · 0.68