我正在使用 switch 语句来检查我正在创建的 libzip zip 存档中错误代码的值。但是,它似乎永远不会返回 0 以外的任何值,即使我故意导致它失败。(我试图将文件复制到 100% 满的 USB 驱动器导致它失败)。
我的用法在这里怎么不正确?
int error = 0;
zip_t * zip = zip_open(externalDevicePath.c_str(), ZIP_CREATE, &error);
zip_add_dir(zip,(institutionId + DIR_SLASH + userId).c_str());
string instAndUserPath = basePath + DIR_SLASH + institutionId + DIR_SLASH + userId;
string stbackupPath = basePath + DIR_SLASH + "STBackups";
ESFileUtilsCommon::addDirectoryToZip(instAndUserPath,zip,(institutionId + DIR_SLASH + userId).c_str());
ESFileUtilsCommon::addDirectoryToZip(stbackupPath,zip,"STBackups");
ESFileUtilsCommon::addDirectoryContentsToZip(basePath, zip);
zip_close(zip);
switch (error){
case ZIP_ER_OK:
mapper.setResult(RESULT_SUCCESS);
retval = CefV8Value::CreateString(mapper.getMappedJsonResponse());
return true;
break;
default:
mapper.setResult(RESULT_FAILURE);
retval = CefV8Value::CreateString(mapper.getMappedJsonResponse());
return false;
break;
}