| 125 | } |
| 126 | |
| 127 | bool LoadPathsFromFile(const char *pArgv0) |
| 128 | { |
| 129 | // check current directory |
| 130 | IOHANDLE File = io_open("storage.cfg", IOFLAG_READ); |
| 131 | if(!File) |
| 132 | { |
| 133 | // check usable path in argv[0] |
| 134 | unsigned int Pos = ~0U; |
| 135 | for(unsigned i = 0; pArgv0[i]; i++) |
| 136 | if(pArgv0[i] == '/' || pArgv0[i] == '\\') |
| 137 | Pos = i; |
| 138 | if(Pos < IO_MAX_PATH_LENGTH) |
| 139 | { |
| 140 | char aBuffer[IO_MAX_PATH_LENGTH]; |
| 141 | str_copy(aBuffer, pArgv0, Pos + 1); |
| 142 | str_append(aBuffer, "/storage.cfg"); |
| 143 | File = io_open(aBuffer, IOFLAG_READ); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | CLineReader LineReader; |
| 148 | if(!LineReader.OpenFile(File)) |
| 149 | { |
| 150 | log_error("storage", "couldn't open storage.cfg"); |
| 151 | return true; |
| 152 | } |
| 153 | while(const char *pLine = LineReader.Get()) |
| 154 | { |
| 155 | const char *pLineWithoutPrefix = str_startswith(pLine, "add_path "); |
| 156 | if(pLineWithoutPrefix) |
| 157 | { |
| 158 | if(!AddPath(pLineWithoutPrefix) && !m_NumPaths) |
| 159 | { |
| 160 | log_error("storage", "failed to add path for the user directory"); |
| 161 | return false; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | if(!m_NumPaths) |
| 167 | { |
| 168 | log_error("storage", "no usable paths found in storage.cfg"); |
| 169 | } |
| 170 | return true; |
| 171 | } |
| 172 | |
| 173 | bool AddDefaultPaths() |
| 174 | { |
nothing calls this directly
no test coverage detected