Cabinet.cpp in MakeCab.rar


Cab files used in the production of the source, a common window platform, the dy...Original Link
    Sponsored links

			
// Cabinet.cpp: implementation of the CCabinet class.
//
//////////////////////////////////////////////////////////////////////

#include "Cabinet.h"


//下面是压缩时用到的回调函数。
/*
 * 分配内存
 */
FNFCIALLOC(mem_alloc)
{
	return malloc(cb);
}


/*
 * 释放内存
 */
FNFCIFREE(mem_free)
{
	free(memory);
}

/*
 * 打开文件
 */
FNFCIOPEN(fci_open)
{
    return _open(pszFile, oflag, pmode);
}

/*
 * 读取文件
 */
FNFCIREAD(fci_read)
{
    return (unsigned int) _read(hf, memory, cb);
}

/*
 * 写文件
 */
FNFCIWRITE(fci_write)
{
    return (unsigned int) _write(hf, memory, cb);
}

/*
 * 关闭文件
 */
FNFCICLOSE(fci_close)
{
   return _close(hf);
}

FNFCISEEK(fci_seek)
{
    return _lseek(hf, dist, seektype);
}

FNFCIDELETE(fci_delete)
{
    return remove(pszFile);
}


FNFCIFILEPLACED(file_placed)
{
	return 0;
}


FNFCIGETTEMPFILE(get_temp_file)
{
    char    *psz;

    psz = _tempnam("","xx");            // Get a name
    if ((psz != NULL) && (strlen(psz) < (unsigned)cbTempName)) {
        strcpy(pszTempName,psz);        // Copy to caller's buffer
        free(psz);                      // Free temporary name buffer
        return TRUE;                    // Success
    }
    //** Failed
    if (psz) {
        free(psz);
    }

    return FALSE;
}


/*
 * 用于压缩过程中的提示信息显示,这里忽略。
 */
FNFCISTATUS(progress)
{
	return 0;
}

/*
 * 这里忽略。
 */
FNFCIGETNEXTCABINET(get_next_cabinet)
{
	return TRUE;
}


FNFCIGETOPENINFO(get_open_info)
{
	BY_HANDLE_FILE_INFORMATION	finfo;
	FILETIME					filetime;
	HANDLE						handle;
    DWORD                       attrs;
    int                         hf;

    /*
     * Need a Win32 type handle to get file date/time
     * using the Win32 APIs, even though the handle we
     * will be returning is of the type compatible with
     * _open
     */
	handle = CreateFile(
		pszName,
		GENERIC_READ			

			...
			...
			... to be continued.

  This is a preview. To get the complete source file, 
  please click here to download the whole source code package.

			
			


Project Files

    Sponsored links
NameSizeDate
 CAB.cpp606.00 B28-07-08 17:01
 CAB.dsp4.32 kB28-07-08 16:41
 CAB.dsw529.00 B07-06-03 08:29
 CAB.ncb49.00 kB29-07-08 10:12
 CAB.opt73.00 kB29-07-08 10:12
 CAB.plg1.42 kB28-07-08 16:59
 Cabinet.cpp10.23 kB07-06-03 16:49
 Cabinet.h1.24 kB07-06-03 16:30
 CABINET.lib3.52 kB07-06-03 11:35
 FCI.H22.53 kB20-03-97 02:01
 FDI.H46.20 kB20-03-97 02:01
 <Debug>0.00 B28-07-08 17:28
 <MakeCab>0.00 B29-07-08 10:12
...

Related Items

    Sponsored links