Skip to content

Commit 461ee5d

Browse files
committed
fixes
1 parent 68c2a7a commit 461ee5d

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed

source/common.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -164,32 +164,34 @@ uint32_t file_crc32(const char* input)
164164

165165
int copy_directory(const char* startdir, const char* inputdir, const char* outputdir)
166166
{
167-
char fullname[256];
167+
char fullname[256];
168168
char out_name[256];
169-
struct dirent *dirp;
170-
int len = strlen(startdir);
171-
DIR *dp = opendir(inputdir);
169+
struct dirent *dirp;
170+
int len = strlen(startdir);
171+
DIR *dp = opendir(inputdir);
172172

173-
if (!dp) {
174-
return FAILED;
175-
}
173+
if (!dp) {
174+
return FAILED;
175+
}
176176

177-
while ((dirp = readdir(dp)) != NULL) {
178-
if ((strcmp(dirp->d_name, ".") != 0) && (strcmp(dirp->d_name, "..") != 0)) {
179-
snprintf(fullname, sizeof(fullname), "%s%s", inputdir, dirp->d_name);
177+
while ((dirp = readdir(dp)) != NULL) {
178+
if ((strcmp(dirp->d_name, ".") != 0) && (strcmp(dirp->d_name, "..") != 0)) {
179+
snprintf(fullname, sizeof(fullname), "%s%s", inputdir, dirp->d_name);
180180

181-
if (dirp->d_type == DT_DIR) {
181+
if (dirp->d_type == DT_DIR) {
182182
strcat(fullname, "/");
183-
copy_directory(startdir, fullname, outputdir);
184-
} else {
185-
snprintf(out_name, sizeof(out_name), "%s%s", outputdir, &fullname[len]);
186-
if (copy_file(fullname, out_name) != SUCCESS) {
187-
return FAILED;
188-
}
189-
}
190-
}
191-
}
192-
closedir(dp);
183+
if (copy_directory(startdir, fullname, outputdir) != SUCCESS) {
184+
return FAILED;
185+
}
186+
} else {
187+
snprintf(out_name, sizeof(out_name), "%s%s", outputdir, &fullname[len]);
188+
if (copy_file(fullname, out_name) != SUCCESS) {
189+
return FAILED;
190+
}
191+
}
192+
}
193+
}
194+
closedir(dp);
193195

194196
return SUCCESS;
195197
}

source/exec_cmd.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static void zipSave(const save_entry_t* entry, const char* exp_path)
141141

142142
static void copySave(const save_entry_t* save, const char* exp_path)
143143
{
144+
int ret;
144145
char copy_path[256];
145146

146147
if (strncmp(save->path, exp_path, strlen(exp_path)) == 0)
@@ -158,12 +159,15 @@ static void copySave(const save_entry_t* save, const char* exp_path)
158159
init_loading_screen("Copying files...");
159160

160161
snprintf(copy_path, sizeof(copy_path), "%s%08x_%s_%s/", exp_path, apollo_config.user_id, save->title_id, save->dir_name);
161-
162162
LOG("Copying <%s> to %s...", save->path, copy_path);
163-
copy_directory(save->path, save->path, copy_path);
164163

164+
ret = copy_directory(save->path, save->path, copy_path);
165165
stop_loading_screen();
166-
show_message("Files successfully copied to:\n%s", exp_path);
166+
167+
if (ret == SUCCESS)
168+
show_message("Files successfully copied to:\n%s", exp_path);
169+
else
170+
show_message("Error! Can't copy save game to:\n%s", exp_path);
167171
}
168172

169173
static int _update_save_details(const char* sys_path, const save_entry_t* save)
@@ -263,6 +267,7 @@ static void downloadSaveHDD(const save_entry_t* entry, const char* file)
263267
if (!extract_zip(APOLLO_LOCAL_CACHE "tmpsave.zip", path))
264268
{
265269
show_message("Error extracting save game!");
270+
orbis_SaveUmount(mount);
266271
return;
267272
}
268273

@@ -279,6 +284,7 @@ static void downloadSaveHDD(const save_entry_t* entry, const char* file)
279284

280285
static int _copy_save_hdd(const save_entry_t* save)
281286
{
287+
int ret;
282288
char copy_path[256];
283289
char mount[ORBIS_SAVE_DATA_DIRNAME_DATA_MAXSIZE];
284290
sfo_patch_t patch = {
@@ -292,7 +298,7 @@ static int _copy_save_hdd(const save_entry_t* save)
292298
snprintf(copy_path, sizeof(copy_path), APOLLO_SANDBOX_PATH, mount);
293299

294300
LOG("Copying <%s> to %s...", save->path, copy_path);
295-
copy_directory(save->path, save->path, copy_path);
301+
ret = copy_directory(save->path, save->path, copy_path);
296302

297303
snprintf(copy_path, sizeof(copy_path), "%s" "sce_sys/", save->path);
298304
_update_save_details(copy_path, save);
@@ -301,7 +307,7 @@ static int _copy_save_hdd(const save_entry_t* save)
301307
patch_sfo(copy_path, &patch);
302308
orbis_SaveUmount(mount);
303309

304-
return 1;
310+
return (ret == SUCCESS);
305311
}
306312

307313
static int _copy_save_pfs(const save_entry_t* save)

source/http.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ int http_download(const char* url, const char* filename, const char* local_dst,
104104
fd = fopen(local_dst, "wb");
105105
if (!fd) {
106106
LOG("fopen Error: File path '%s'", local_dst);
107+
curl_easy_cleanup(curl);
107108
return HTTP_FAILED;
108109
}
109110

@@ -184,6 +185,7 @@ int ftp_upload(const char* local_file, const char* url, const char* filename, in
184185
if(!fd)
185186
{
186187
LOG("Couldn't open '%s'", local_file);
188+
curl_easy_cleanup(curl);
187189
return HTTP_FAILED;
188190
}
189191

0 commit comments

Comments
 (0)