Skip to content

Commit bf0b68e

Browse files
committed
Refactor CreateDirectoryUnderInstDir and update error handling
1 parent 0e845cd commit bf0b68e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/inst_dir.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,28 @@ bool CreateDirectoryUnderInstDir(const char *rel_path)
192192
return false;
193193
}
194194

195-
if (rel_path == NULL) {
195+
if (!rel_path) {
196+
APP_ERROR("relative path is NULL");
196197
return false;
197198
}
198199

199-
if (*rel_path == '\0') {
200+
/* Treat empty string as a no-op and return success */
201+
if (rel_path[0] == '\0') {
200202
return true;
201203
}
202204

203205
char *dir = ExpandInstDirPath(rel_path);
204-
if (dir == NULL) {
206+
if (!dir) {
207+
APP_ERROR("Failed to build full path");
205208
return false;
206209
}
207210

208211
bool result = CreateDirectoriesRecursively(dir);
209212
if (!result) {
210-
APP_ERROR("Failed to create directory under installation directory (InstDir): '%s'", dir);
213+
APP_ERROR(
214+
"Failed to create directory under installation directory: '%s'",
215+
dir
216+
);
211217
}
212218

213219
free(dir);

0 commit comments

Comments
 (0)