MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / NormalizePath

Function NormalizePath

Source/ThirdParty/tracy/client/TracyCallstack.cpp:904–957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

902#endif
903
904char* NormalizePath( const char* path )
905{
906 if( path[0] != '/' ) return nullptr;
907
908 const char* ptr = path;
909 const char* end = path + strlen( path );
910
911 char* res = (char*)tracy_malloc( end - ptr + 1 );
912 size_t rsz = 0;
913
914 while( ptr < end )
915 {
916 const char* next = ptr;
917 while( next < end && *next != '/' ) next++;
918 size_t lsz = next - ptr;
919 switch( lsz )
920 {
921 case 2:
922 if( memcmp( ptr, "..", 2 ) == 0 )
923 {
924 const char* back = res + rsz - 1;
925 while( back > res && *back != '/' ) back--;
926 rsz = back - res;
927 ptr = next + 1;
928 continue;
929 }
930 break;
931 case 1:
932 if( *ptr == '.' )
933 {
934 ptr = next + 1;
935 continue;
936 }
937 break;
938 case 0:
939 ptr = next + 1;
940 continue;
941 }
942 if( rsz != 1 ) res[rsz++] = '/';
943 memcpy( res+rsz, ptr, lsz );
944 rsz += lsz;
945 ptr = next + 1;
946 }
947
948 if( rsz == 0 )
949 {
950 memcpy( res, "/", 2 );
951 }
952 else
953 {
954 res[rsz] = '\0';
955 }
956 return res;
957}
958
959void InitCallstackCritical()
960{

Callers 15

SymbolAddressDataCbFunction · 0.85
CallstackDataCbFunction · 0.85
TestNormalizePathFunction · 0.85
OnInitMethod · 0.85
GetSpecialFolderPathMethod · 0.85
AreFilePathsEqualMethod · 0.85
AreFilePathsEqualMethod · 0.85
GetSpecialFolderPathMethod · 0.85

Calls 3

tracy_mallocFunction · 0.85
memcmpFunction · 0.85
memcpyFunction · 0.85

Tested by 1

TestNormalizePathFunction · 0.68