7.2.3.2 LZNV SDK MFC App File Contents


   7.2.3.2 Function LZNV Decode File


LZNV_Decode_File is a sample function that performs file decompression without the need of any prior buffer manipulation, using the LZNV DLL Object


/// \brief      LZNV_Decode_File performs a straight forward file decompression without the need of any prior buffer manipulation.

/// \note       The function will perform internal buffering. If you want to perform your own buffering, please use LZNV_Decode_File_wBuffer.

/// \param[in]  _wchr_filename_to_decompress: Input file path to decompress. Unicode WCHAR.

/// \param[in]  _wchr_output_filename: Output file path to decompress. This file will be a replica of the _wchr_filename_to_compress. See LZNV_Encode_File function. Unicode WCHAR.

/// \return     returns _LZNV_NO_ERROR (0) in case of no errors or one of the error codes defined in LZNV_Defines.h header file.

///             possible values:

///             - _LZNV_ERROR_INVALID_COMPRESSION_METHOD      

///             - _LZNV_ERROR_INVALID_BUFFER_SIZE            

///             - _LZNV_ERROR_EXPORTED_MAIN_FUNC_NOT_FOUND    

///             - _LZNV_ERROR_INVALID_PROCESS_SIZE            


int32_t CMFCAppClientDlg::LZNV_Decode_File(const wchar_t* _wchr_filename_to_decompress, const wchar_t* _wchr_output_filename)

{

    int32_t _res = 0;


    ASSERT(_p_LZNV_DLL_Main_funct);

    if (!_p_LZNV_DLL_Main_funct) {      

        MessageBox(L"LZNV DLL Not Loaded? Aborting...", L"Error", IDOK);

        return 1;

    }


    ASSERT(_wchr_output_filename);

    ASSERT(_wchr_filename_to_decompress);

    if ((!_wchr_filename_to_decompress) || (!_wchr_output_filename)) {

        MessageBox(L"LZNV DLL passed NULL parameters...", L"Error", IDOK);

        return 1;

    }


    {

        LZNV_FILE_COMMAND_PARAMS _lznv_file_commands = { 0 };


        _lznv_file_commands._command_to_execute = _LZNV_COMMAND_DECODE;

        _lznv_file_commands._cpu_priority_level = _LZNV_NORMAL_PRIORITY_CLASS;


        ASSERT(_wchr_filename_to_decompress);

        wcsncpy_s(_lznv_file_commands._source_file_path, _wchr_filename_to_decompress, _LZNV_MAXPATH_);


        ASSERT(_wchr_output_filename);

        wcsncpy_s(_lznv_file_commands._target_file_path, _wchr_output_filename, _LZNV_MAXPATH_);


        _res = (*_p_LZNV_DLL_Main_funct)(_lznv_file_commands);

    }


    CString csStrResult;

    csStrResult.Format(L"LZNV DLL returned result = %d", _res);

    m_stDecodeResult.SetWindowText(csStrResult);


    return _res;

}