| 182 | } |
| 183 | |
| 184 | static int zipAddPath(zipFile zf, const char *path, int filename_start, int level, FileProcessParam *param) { |
| 185 | SceUID dfd = sceIoDopen(path); |
| 186 | if (dfd >= 0) { |
| 187 | int ret = zipAddFolder(zf, path, filename_start, level, param); |
| 188 | if (ret <= 0) |
| 189 | return ret; |
| 190 | |
| 191 | int res = 0; |
| 192 | |
| 193 | do { |
| 194 | SceIoDirent dir; |
| 195 | memset(&dir, 0, sizeof(SceIoDirent)); |
| 196 | |
| 197 | res = sceIoDread(dfd, &dir); |
| 198 | if (res > 0) { |
| 199 | char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2); |
| 200 | snprintf(new_path, MAX_PATH_LENGTH, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name); |
| 201 | |
| 202 | int ret = 0; |
| 203 | |
| 204 | if (SCE_S_ISDIR(dir.d_stat.st_mode)) { |
| 205 | ret = zipAddPath(zf, new_path, filename_start, level, param); |
| 206 | } else { |
| 207 | ret = zipAddFile(zf, new_path, filename_start, level, param); |
| 208 | } |
| 209 | |
| 210 | free(new_path); |
| 211 | |
| 212 | // Some folders are protected and return 0x80010001. Bypass them |
| 213 | if (ret <= 0 && ret != 0x80010001) { |
| 214 | sceIoDclose(dfd); |
| 215 | return ret; |
| 216 | } |
| 217 | } |
| 218 | } while (res > 0); |
| 219 | |
| 220 | sceIoDclose(dfd); |
| 221 | } else { |
| 222 | return zipAddFile(zf, path, filename_start, level, param); |
| 223 | } |
| 224 | |
| 225 | return 1; |
| 226 | } |
| 227 | |
| 228 | int makeZip(const char *zip_file, const char *src_path, int filename_start, int level, int append, FileProcessParam *param) { |
| 229 | zipFile zf = zipOpen64(zip_file, append); |
no test coverage detected