⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mixedio.cpp

📁 非常好用的五子棋游戏源码
💻 CPP
字号:
// Created:11-15-98
// By Jeff Connelly

// Mixed file I/O: using file I/O and memory I/O at the same time

#include "comprlib.h"
#include <stdio.h>
#include <stdlib.h>

const char* help = "Encodes a file to memory\n"
                   "\tMIXEDIO source dest\n"
                   "source is encoded to memory, then the memory is\n"
                   "decoded to dest.  The encoded data is lost\n";

int main(int argc, char* argv[])
{
    if (argc != 3)
    {
        printf(help);
        exit (0);
    }

    // Use file I/O for input, memory for output.  In other words, we will
    // compress a file to memory.  File -> memory
    ComprLibFileIO::SetInput();
    ComprLibMemIO::SetOutput();

    ComprLibFileIO::source_file = fopen(argv[1], "rb");
    if (!ComprLibFileIO::source_file)
    {
        printf ("Cannot open file\n");
        exit (1);
    }

    ComprLibMemIO::dest_ptr = xmalloc(1);
    ComprLibMemIO::dest_len = 1;

    // Now we can encode it
    printf("Encoding...\n");
    lzss_encode();

    fclose(ComprLibFileIO::source_file);

    // We now decode it to memory.  Memory -> file
    ComprLibFileIO::SetOutput();
    ComprLibMemIO::SetInput();

    // The destination file is the second argument
    ComprLibFileIO::dest_file = fopen(argv[2], "wb");
    if (!ComprLibFileIO::dest_file)
    {
        printf ("Cannot open file\n");
        exit (2);
    }
    // Just because we are not using output of memory does not mean that
    // the pointers are still not valid.
    ComprLibMemIO::source_ptr = ComprLibMemIO::dest_ptr;
    ComprLibMemIO::dest_ptr = NULL;     // Not using it anymore
    ComprLibMemIO::source_len = ComprLibMemIO::dest_len;
    ComprLibMemIO::dest_len = 0;

    printf("Decoding...\n");
    lzss_decode();

    xfree(ComprLibMemIO::source_ptr);
}


    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -