* Open the file read only. The call fails if the file doesn't exist. * * Returns NULL on failure. */
| 39 | * Returns NULL on failure. |
| 40 | */ |
| 41 | ZipFile* openReadOnly(const char* fileName) |
| 42 | { |
| 43 | ZipFile* zip; |
| 44 | status_t result; |
| 45 | |
| 46 | zip = new ZipFile; |
| 47 | result = zip->open(fileName, ZipFile::kOpenReadOnly); |
| 48 | if (result != NO_ERROR) { |
| 49 | if (result == NAME_NOT_FOUND) |
| 50 | fprintf(stderr, "ERROR: '%s' not found\n", fileName); |
| 51 | else if (result == PERMISSION_DENIED) |
| 52 | fprintf(stderr, "ERROR: '%s' access denied\n", fileName); |
| 53 | else |
| 54 | fprintf(stderr, "ERROR: failed opening '%s' as Zip file\n", |
| 55 | fileName); |
| 56 | delete zip; |
| 57 | return NULL; |
| 58 | } |
| 59 | |
| 60 | return zip; |
| 61 | } |
| 62 | |
| 63 | /* |
| 64 | * Open the file read-write. The file will be created if it doesn't |