MCPcopy Create free account
hub / github.com/ddnet/ddnet / AddPath

Method AddPath

src/engine/shared/storage.cpp:186–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184 }
185
186 bool AddPath(const char *pPath)
187 {
188 if(!pPath[0])
189 {
190 log_error("storage", "cannot add empty path");
191 return false;
192 }
193 if(m_NumPaths >= MAX_PATHS)
194 {
195 log_error("storage", "cannot add path '%s', the maximum number of paths is %d", pPath, MAX_PATHS);
196 return false;
197 }
198
199 if(!str_comp(pPath, "$USERDIR"))
200 {
201 if(m_aUserdir[0])
202 {
203 str_copy(m_aaStoragePaths[m_NumPaths++], m_aUserdir);
204 log_info("storage", "added path '$USERDIR' ('%s')", m_aUserdir);
205 return true;
206 }
207 else
208 {
209 log_error("storage", "cannot add path '$USERDIR' because it could not be determined");
210 return false;
211 }
212 }
213 else if(!str_comp(pPath, "$DATADIR"))
214 {
215 if(m_aDatadir[0])
216 {
217 str_copy(m_aaStoragePaths[m_NumPaths++], m_aDatadir);
218 log_info("storage", "added path '$DATADIR' ('%s')", m_aDatadir);
219 return true;
220 }
221 else
222 {
223 log_error("storage", "cannot add path '$DATADIR' because it could not be determined");
224 return false;
225 }
226 }
227 else if(!str_comp(pPath, "$CURRENTDIR"))
228 {
229 m_aaStoragePaths[m_NumPaths++][0] = '\0';
230 log_info("storage", "added path '$CURRENTDIR' ('%s')", m_aCurrentdir);
231 return true;
232 }
233 else if(str_utf8_check(pPath))
234 {
235 if(fs_is_dir(pPath))
236 {
237 str_copy(m_aaStoragePaths[m_NumPaths++], pPath);
238 log_info("storage", "added path '%s'", pPath);
239 return true;
240 }
241 else
242 {
243 log_error("storage", "cannot add path '%s', which is not a directory", pPath);

Callers 2

CreateLocalStorageFunction · 0.80
CreateTempStorageFunction · 0.80

Calls 4

str_compFunction · 0.85
str_utf8_checkFunction · 0.85
fs_is_dirFunction · 0.85
str_copyFunction · 0.50

Tested by

no test coverage detected