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

📄 fpcio.cpp

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

// COMPRLIB data I/O.

// This file, FPCIO.CPP, is file I/O with a progress bar.  It is based on the
// code from FCIO.CPP.

#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#define EXPORTING
#include "comprlib.h"

#include "fpcio.h"

// These are the file variables.  They *must* be set before calling any
// compression/uncompression function.
FILE* source_file;
FILE* dest_file;

// 'progress_char' is the character to use for the progress meter.
char progress_char = '.';

// 'progress_incr' how often the progress bar should be updated. 
double progress_incr = 0.01;

// How many bytes to read before considering the file to be considered at
// the end.  For example, a file might have extra data at the end that
// must not be (de)compressed.
long file_limit = 0;

// Hidden variables that you should not use
static bool byte_stored_status = false;
static int val_byte_stored;

// Returns 'true' if there is more data to read, else false.  The global
// variable 'file_limit' can be set to deturmine the end of the file if you
// want all of the file not to be read.  If the file limit is set to 0,
// the end of data state will be based on result of 'feof' function.
bool end_of_data()
{
    if (file_limit)                  // Non-zero, use this value
        return ftell(source_file) >= file_limit;
    else
        return feof(source_file);
}

// Reads a byte and returns it's value
unsigned char read_byte()
{
    static int prevsize = 0;
    static int bytesread = 1;

    printf ("%d\n", (bytesread++ / filelength(fileno(source_file))) * 100);

    // If a byte is stored, return it's value
    if (byte_stored_status)
    {
        byte_stored_status = false;
        return (unsigned char)val_byte_stored;
    }
    // If not, just return a byte
    return (unsigned char)fgetc(source_file);

}

// Writes a byte to the output stream
void write_byte(unsigned char byte)
{
    fputc (byte, dest_file);
}

// Sets the position to the beginning of the data stream
void beginning_of_data()
{
    byte_stored_status = false;
    rewind (source_file);
}

// Returns the length of the input stream
long stream_size ()
{
    fseek (source_file, 0, SEEK_END);
    return ftell (source_file);
}

// Writes an array to the output stream
void write_array (void* array, int bytes)
{
    fwrite(array, 1, bytes, dest_file);
}

// Writess a block, used for RLE type 1 decompression
void write_block(unsigned char byte, int time_nb)
{
    unsigned char array_to_write[129];
    memset(array_to_write, byte, time_nb);
    write_array (array_to_write, time_nb);
}

⌨️ 快捷键说明

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