int DownloadObjectRequest::validate()

in sdk/src/resumable/DownloadObjectRequest.cc [105:140]


int DownloadObjectRequest::validate() const
{
    auto ret = OssResumableBaseRequest::validate();
    if (ret != 0) {
        return ret;
    }

    if (rangeIsSet_ && (range_[0] < 0 || range_[1] < -1 || (range_[1] > -1 && range_[1] < range_[0]))) {
        return ARG_ERROR_INVALID_RANGE;
    }

#if !defined(_WIN32)
    if (!filePathW_.empty()) {
        return ARG_ERROR_PATH_NOT_SUPPORT_WSTRING_TYPE;
    }
#endif

    if (filePath_.empty() && filePathW_.empty()) {
        return ARG_ERROR_DOWNLOAD_FILE_PATH_EMPTY;
    }

    //path and checkpoint must be same type.
    if ((!filePath_.empty() && !checkpointDirW_.empty()) ||
        (!filePathW_.empty() && !checkpointDir_.empty())) {
        return ARG_ERROR_PATH_NOT_SAME_TYPE;
    }

    //check tmpfilePath is available
    auto stream = GetFstreamByPath(tempFilePath_, tempFilePathW_, std::ios::out | std::ios::app);
    if (!stream->is_open()) {
        return ARG_ERROR_OPEN_DOWNLOAD_TEMP_FILE;
    }
    stream->close();

    return 0;
}