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

📄 resmgr.h

📁 空战游戏flacon源码
💻 H
📖 第 1 页 / 共 3 页
字号:
/* ----------------------------------------------------------------------
   Resource Manager

   Version 2.00                    Released 03/09/97

   Written by Kevin Ray (x301)	   (c) 1996 Spectrum Holobyte
   ----------------------------------------------------------------------

   ResInit              - start up the resource manager
   ResExit              - shut down the resource manager

   ResMountCD           - mount the CD
   ResDismountCD        - unmount a previously mounted CD
   ResAttach            - opens an archive file (zip file) and attaches it to a directory point
   ResDetach            - closes an archive file

   ResCheckMedia        - check to see if media in device has been changed
  
   ResOpenFile          - open a file for read/write
   ResReadFile          - read a file into a buffer
   ResLoadFile          - load an entire file into memory
   ResCloseFile         - closes a previously opened file
   ResWriteFile         - write to an opened file
   ResDeleteFile        - delete a file (only from HD obviously)
   ResModifyFile        - modify the attributes of a file
   ResSeekFile          - seek within an opened file
   ResTellFile          - returns the offset into the file of the current read position
   ResFlushFile         - write any buffer to the opened file
   ResSizeFile          - get the uncompressed size of a file

   ResExistFile         - does a file exist
   ResExistDirectory    - does a directory exist
   
   ResMakeDirectory     - create a directory
   ResDeleteDirectory   - remove a directory and any held files
   ResOpenDirectory     - open a directory for read (similiar to _findfirst() - same as opendir())
   ResReadDirectory     - read the contents of a directory (similiar to _findnext())
   ResCloseDirectory    - close a directory (similiar to _findclose() - same as closedir())
   ResSetDirectory      - set the current working directory
   ResGetDirectory      - return the current working directory
   ResCountDirectory    - return the number of files found in directory

   ResBuildPathname     - convenience function for concatenating strings to system paths
   ResAssignPath        - name the system paths (optional)
   ResOverride          - override any previously found files with those found in this directory

   ResSetCD             - set the current CD drive volume
   ResGetCD             - return the current CD drive volume
   
   ResCreatePath        - creates a search path (releases any previous)
   ResAddPath           - adds a directory to the search path
   ResGetPath           - returns the nth entry in the search path

   ResRemovePath        - removes a directory from the search path
   ResRemoveTree        - removes a directory (recursively) from the search path
   
   ResWhereIs           - returns the location of a file
   ResWhichCD           - returns the current cd number
   ResWriteTOC          - writes the unified table-of-contents file
   
   ResStatusFile        - returns the status of a file
   
   ResAsynchRead        - asynchronous read  (context of read thread)
   ResAsynchWrite       - asynchronous write
   
   ResFOpen             - stdio style streams (fopen)
   ResFClose            - stdio style streams (fclose)
   ResSetBuf            - stdio style streams (setvbuf)

   ResOpenStream        - YET TO BE IMPLEMENTED
   ResDefineStream      -
   ResPlayStream        -  CDI / 3DO style streams
   ResWriteStream       -
   
   ResDbg               - turn debugging on and off
   ResDbgLogOpen        - open a log file
   ResDbgLogClose       - close a log file
   ResDbgLogPause       - toggle the paused state of event logging
   ResDbgDump           - dump debug statistic

   ---------------------------------------------------------------------- */

#ifndef RESOURCE_MANAGER
#  define RESOURCE_MANAGER    1

#include <stdlib.h>       /* _MAX_FNAME, _MAX_PATH                                        */
#include <stdio.h>        /* FILE*                                                        */

#include "omni.h"  /* The configuration options */
                                           
#if !defined(__LISTS_H_INCLUDED)
#   define LIST void
#endif /* __LISTS_H_INCLUDED */

// Must comment this out if you're not on windows, but
// the following header stuff really requires it.
#include <windows.h>      /* all this for MessageBox (may move to debug.cpp)              */
#include <io.h>

/* ---------------------------------------------------------------------



/* ----------------------------------------------------------------------

        G E N E R A L   C O M P I L E R   D E F I N I T I O N S

   ---------------------------------------------------------------------- */

#define MAX_DIR_DEPTH                   25      /* maximum depth of directory nesting           */
#define MAX_DIRECTORY_DEPTH             25      /* chop one of em                               */
#define MAX_FILENAME                    60      /* maximum length of a filename                 */
//#define MAX_DIRECTORIES                 500     /* maximum number of directories in search path */
                                                    /* moved to omni.h GFG 3.11.98 */
#define MAX_CD                          2       /* maximum number of cd's allowed               */
#define MAX_READ_SIZE                   32767   /* maximum buffer to read in a single ResRead   */
#define MAX_FILE_HANDLES                256      /* maximum number of open files                 */
#define MAX_DEVICES                     26      /* number of devices to keep track of (A-Z)     */

#define FILENAME_LENGTH                 14      /* for 8.3 naming convention use 14             */

#define STRING_SAFETY_SIZE              0.85    /* safety buffer ratio for string pools         */

#ifdef _DLL_VERSION
#   define RES_EXPORT  CFUNC __declspec (dllexport)
#else
#   define RES_EXPORT  CFUNC
#endif


/* ----------------------------------------------------------------------

        H A S H   T A B L E    O P T I O N S

   ---------------------------------------------------------------------- */

    //       for all these values, the 'primer' the better      //

#if( RES_USE_FLAT_MODEL )
#    define HASH_TABLE_SIZE       211      /* needs to hold all the files           */

#    define ARCHIVE_TABLE_SIZE    53       /* size of hash table to start with when 
                                              opening an archive.  since there is no 
                                              simple entry in a zip file containing
                                              the number of entries within a zip file, 
                                              and since counting the entries is a 
                                              rather laborious process - this value 
                                              is used as the starting point.  If the 
                                              number of entries exceed this value, 
                                              the hash table size is dynamically
                                              resized. */
#else /* otherwise, heirarchical */
#    define HASH_TABLE_SIZE       29       /* only needs to hold directory names    */

#    define ARCHIVE_TABLE_SIZE    29       /* if you are using hierarchies, and
                                              you have recursed directory pathnames
                                              into the zip, you can probably use the
                                              same size hash table for archive table
                                              as what you defined as HASH_TABLE_SIZE */
#endif /* RES_USE_FLAT_MODEL */

/* ----------------------------------------------------------------------

    HASH_TABLE_SIZE is the default size for the main hash table.  The hash 
    table will grow if you try to put too many entries into it, but this 
    is the starting point.  I try to maintain about 125% hash size vs. 
    number of entries, but I only trigger a resize of the hash table when 
    you get to 80% hash size vs. number of entries (20% more entries than 
    slots). 

   ---------------------------------------------------------------------- */

#define HASH_OPTIMAL_RATIO        1.15    /* 1.15 == 115 percent                    */
#define HASH_MINIMAL_RATIO        0.80    /* 0.80 == 80 percent                     */

#define HASH_CONST                26      /* kind of like a seed value              */

#define USE_AFU                   YES     /* hash function used in STTNG:AFU        */
#define USE_SEDGEWICK             NO     /* hash function from Alogrithms in C     */





/* ----------------------------------------------------------------------

        I N T E R F A C E   F U N C T I O N S

   ---------------------------------------------------------------------- */

//#define RES_DEBUG_STDIO(msg,len)        OutputDebugString(msg)    


/* ------------------------------------------------------------
    RES_DEBUG_STDIO

    Either define with your own message handler, for example:

    #define RES_DEBUG_STDIO(msg,len)    printf(msg)
    #define RES_DEBUG_STDIO(msg,len)    DebugStdio(msg,len)

    or, if you don't want any logging, or only want events 
    logged to a file, then don't define RES_DEBUG_STDIO.

    Also, don't define it as ResDbgPrintf or you will 
    get infinite recursion.
   ------------------------------------------------------------ */






/* -------------------------------------------------------------------------------

        E N U M E R A T I O N   T A B L E S

   ------------------------------------------------------------------------------- */


/* ----- ERROR CODES ----- */

enum RES_ERRORS                           
{
    RES_ERR_FIRST_ERROR = -5000,
    RES_ERR_NO_MEMORY,
    RES_ERR_INCORRECT_PARAMETER,
    RES_ERR_PATH_NOT_FOUND,
	RES_ERR_FILE_SHARING,
    RES_ERR_ILLEGAL_CD,

⌨️ 快捷键说明

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