MCPcopy Create free account
hub / github.com/beefytech/Beef / FixFilePath

Method FixFilePath

BeefFuzz/BeefFuzz.h:36–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34{
35public:
36 static bool FixFilePath(String& filePath)
37 {
38 if (filePath.length() == 0)
39 return false;
40
41 if (filePath[0] == '<')
42 return false;
43
44 if ((filePath.length() > 1) && (filePath[1] == ':'))
45 filePath[0] = tolower(filePath[0]);
46
47 bool prevWasSlash = false;
48 for (int i = 0; i < filePath.length(); i++)
49 {
50 //if ((filePath[i] == '/') && (filePath[i - 1])
51
52 if (filePath[i] == DIR_SEP_CHAR_ALT)
53 filePath[i] = DIR_SEP_CHAR;
54
55 if (filePath[i] == DIR_SEP_CHAR)
56 {
57 if ((prevWasSlash) && (i > 1))
58 {
59 filePath.Remove(i, 1);
60 i--;
61 continue;
62 }
63
64 prevWasSlash = true;
65 }
66 else
67 prevWasSlash = false;
68
69 if ((i >= 4) && (filePath[i - 3] == DIR_SEP_CHAR) && (filePath[i - 2] == '.') && (filePath[i - 1] == '.') && (filePath[i] == DIR_SEP_CHAR))
70 {
71 int prevSlash = (int)filePath.LastIndexOf(DIR_SEP_CHAR, i - 4);
72 if (prevSlash != -1)
73 {
74 filePath.Remove(prevSlash, i - prevSlash);
75 i = prevSlash;
76 }
77 }
78 }
79 return true;
80 }
81
82 static void GetDirWithSlash(String& dirName)
83 {

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.45
RemoveMethod · 0.45
LastIndexOfMethod · 0.45

Tested by

no test coverage detected