Initial commit of Command & Conquer Red Alert source code.

This commit is contained in:
LFeenanEA
2025-02-27 16:15:05 +00:00
parent b685cea758
commit 5e733d5dcc
2082 changed files with 797727 additions and 0 deletions

604
WIN32LIB/RAWFILE/CCFILE.CPP Normal file
View File

@@ -0,0 +1,604 @@
/*
** Command & Conquer Red Alert(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c0\vcs\code\ccfile.cpv 2.20 27 Sep 1995 12:45:16 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : CCFILE.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : August 8, 1994 *
* *
* Last Update : March 20, 1995 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* CCFileClass::CCFileClass -- Default constructor for file object. *
* CCFileClass::CCFileClass -- Filename based constructor for C&C file. *
* CCFileClass::Close -- Closes the file. *
* CCFileClass::Is_Available -- Checks for existence of file on disk or in mixfile. *
* CCFileClass::Is_Open -- Determines if the file is open. *
* CCFileClass::Open -- Opens a file from either the mixfile system or the rawfile system. *
* CCFileClass::Read -- Reads data from the file. *
* CCFileClass::Seek -- Moves the current file pointer in the file. *
* CCFileClass::Size -- Determines the size of the file. *
* CCFileClass::Write -- Writes data to the file (non mixfile files only). *
* CCFileClass::Error -- Handles displaying a file error message. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include <direct.h>
#include <fcntl.h>
#include <io.h>
#include <dos.h>
#include <errno.h>
#include <share.h>
#include "ccfile.h"
/***********************************************************************************************
* CCFileClass::Error -- Handles displaying a file error message. *
* *
* Display an error message as indicated. If it is allowed to retry, then pressing a key *
* will return from this function. Otherwise, it will exit the program with "exit()". *
* *
* INPUT: error -- The error number (same as the DOSERR.H error numbers). *
* *
* canretry -- Can this routine exit normally so that retrying can occur? If this is *
* false, then the program WILL exit in this routine. *
* *
* filename -- Optional filename to report with this error. If no filename is *
* supplied, then no filename is listed in the error message. *
* *
* OUTPUT: none, but this routine might not return at all if the "canretry" parameter is *
* false or the player pressed ESC. *
* *
* WARNINGS: This routine may not return at all. It handles being in text mode as well as *
* if in a graphic mode. *
* *
* HISTORY: *
* 10/17/1994 JLB : Created. *
*=============================================================================================*/
void CCFileClass::Error(int , int , char const * )
{
if (!Force_CD_Available(RequiredCD)) {
Prog_End();
exit(EXIT_FAILURE);
}
}
/***********************************************************************************************
* CCFileClass::CCFileClass -- Filename based constructor for C&C file. *
* *
* Use this constructor for a file when the filename is known at construction time. *
* *
* INPUT: filename -- Pointer to the filename to use for this file object. *
* *
* OUTPUT: none *
* *
* WARNINGS: The filename pointer is presumed to be inviolate throughout the duration of *
* the file object. If this is not guaranteed, then use the default constructor *
* and then set the name manually. *
* *
* HISTORY: *
* 03/20/1995 JLB : Created. *
*=============================================================================================*/
CCFileClass::CCFileClass(char const *filename)
{
Set_Name(filename);
FromDisk = false;
Pointer = 0;
Position = 0;
Length = 0;
Start = 0;
}
/***********************************************************************************************
* CCFileClass::CCFileClass -- Default constructor for file object. *
* *
* This is the default constructor for a C&C file object. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 03/20/1995 JLB : Created. *
*=============================================================================================*/
CCFileClass::CCFileClass(void) : CDFileClass()
{
FromDisk = false;
Pointer = 0;
Position = 0;
Length = 0;
Start = 0;
}
/***********************************************************************************************
* CCFileClass::Write -- Writes data to the file (non mixfile files only). *
* *
* This routine will write data to the file, but NOT to a file that is part of a mixfile. *
* *
* INPUT: buffer -- Pointer to the buffer that holds the data to be written. *
* *
* size -- The number of bytes to write. *
* *
* OUTPUT: Returns the number of bytes actually written. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/08/1994 JLB : Created. *
*=============================================================================================*/
long CCFileClass::Write(void const *buffer, long size)
{
/*
** If this is part of a mixfile, then writing is not allowed. Error out with a fatal
** message.
*/
if (Pointer || FromDisk) {
Error(EACCES, false, File_Name());
}
return(CDFileClass::Write(buffer, size));
}
/***********************************************************************************************
* CCFileClass::Read -- Reads data from the file. *
* *
* This routine determines if the file is part of the mixfile system. If it is, then *
* the file is copied from RAM if it is located there. Otherwise it is read from disk *
* according to the correct position of the file within the parent mixfile. *
* *
* INPUT: buffer -- Pointer to the buffer to place the read data. *
* *
* size -- The number of bytes to read. *
* *
* OUTPUT: Returns the actual number of bytes read (this could be less than requested). *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/08/1994 JLB : Created. *
*=============================================================================================*/
long CCFileClass::Read(void *buffer, long size)
{
int opened = false;
if (!Is_Open()) {
if (Open()) {
opened = true;
}
}
/*
** If the file is part of a loaded mixfile, then a mere copy is
** all that is required for the read.
*/
if (Pointer) {
long maximum = Length - Position;
size = MIN(maximum, size);
if (size) {
Mem_Copy(Add_Long_To_Pointer(Pointer, Position), buffer, size);
Position += size;
}
if (opened) Close();
return(size);
}
/*
** If the file is part of a mixfile, but the mixfile is located
** on disk, then a special read operation is necessary.
*/
if (FromDisk) {
long maximum = Length - Position;
size = MIN(maximum, size);
if (size > 0) {
CDFileClass::Seek(Start + Position, SEEK_SET);
size = CDFileClass::Read(buffer, size);
Position += size;
}
if (opened) Close();
return(size);
}
long s = CDFileClass::Read(buffer, size);
if (opened) Close();
return(s);
}
/***********************************************************************************************
* CCFileClass::Seek -- Moves the current file pointer in the file. *
* *
* This routine will change the current file pointer to the position specified. It follows *
* the same rules the a normal Seek() does, but if the file is part of the mixfile system, *
* then only the position value needs to be updated. *
* *
* INPUT: pos -- The position to move the file to relative to the position indicated *
* by the "dir" parameter. *
* *
* dir -- The direction to affect the position change against. This can be *
* either SEEK_CUR, SEEK_END, or SEEK_SET. *
* *
* OUTPUT: Returns with the position of the new location. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/08/1994 JLB : Created. *
*=============================================================================================*/
long CCFileClass::Seek(long pos, int dir)
{
if (Pointer || FromDisk) {
switch (dir) {
case SEEK_END:
Position = Length;
break;
case SEEK_SET:
Position = 0;
break;
case SEEK_CUR:
default:
break;
}
Position += pos;
if (Position < 0) Position = 0;
if (Position > Length) Position = Length;
return(Position);
}
return(CDFileClass::Seek(pos, dir));
}
/***********************************************************************************************
* CCFileClass::Size -- Determines the size of the file. *
* *
* If the file is part of the mixfile system, then the size of the file is already *
* determined and available. Otherwise, go to the low level system to find the file *
* size. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with the size of the file in bytes. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/08/1994 JLB : Created. *
*=============================================================================================*/
long CCFileClass::Size(void)
{
if (Pointer || FromDisk) return(Length);
return(CDFileClass::Size());
}
/***********************************************************************************************
* CCFileClass::Is_Available -- Checks for existence of file on disk or in mixfile. *
* *
* This routine will examine the mixfile system looking for the file. If the file could *
* not be found there, then the disk is examined directly. *
* *
* INPUT: none *
* *
* OUTPUT: bool; Is the file available for opening? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/08/1994 JLB : Created. *
*=============================================================================================*/
int CCFileClass::Is_Available(int )
{
if (MixFileClass::Offset(File_Name())) {
return(true);
}
return(CDFileClass::Is_Available());
}
/***********************************************************************************************
* CCFileClass::Is_Open -- Determines if the file is open. *
* *
* A mixfile is open if there is a pointer to the mixfile data. In absence of this, *
* the the file is open if the file handle is valid. *
* *
* INPUT: none *
* *
* OUTPUT: bool; Is the file open? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/08/1994 JLB : Created. *
*=============================================================================================*/
int CCFileClass::Is_Open(void) const
{
/*
** If the file is part of a cached file, then return that it is opened. A closed file
** doesn't have a valid pointer.
*/
if (Pointer) return(true);
return(CDFileClass::Is_Open());
}
/***********************************************************************************************
* CCFileClass::Close -- Closes the file. *
* *
* If this is a mixfile file, then only the pointers need to be adjusted. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/08/1994 JLB : Created. *
*=============================================================================================*/
void CCFileClass::Close(void)
{
FromDisk = false;
Pointer = 0;
Position = 0; // Starts at beginning offset.
Start = 0;
Length = 0;
CDFileClass::Close();
}
/***********************************************************************************************
* CCFileClass::Open -- Opens a file from either the mixfile system or the rawfile system. *
* *
* This routine will open the specified file. It examines the mixfile system to find a *
* match. If one is found then the file is "opened" in a special cached way. Otherwise *
* it is opened as a standard DOS file. *
* *
* INPUT: rights -- The access rights desired. *
* *
* OUTPUT: bool; Was the file opened successfully? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/08/1994 JLB : Created. *
*=============================================================================================*/
int CCFileClass::Open(int rights)
{
/*
** Always close the file if it was open.
*/
Close();
/*
** Perform a preliminary check to see if the specified file
** exists on the disk. If it does, then open this file regardless
** of whether it also exists in RAM. This is slower, but allows
** upgrade files to work.
*/
if ((rights & WRITE) || CDFileClass::Is_Available()) {
return(CDFileClass::Open(rights));
}
/*
** Check to see if file is part of a mixfile and that mixfile is currently loaded
** into RAM.
*/
MixFileClass *mixfile = 0;
if (MixFileClass::Offset(File_Name(), &Pointer, &mixfile, &Start, &Length)) {
/*
** If the mixfile is located on disk, then fake out the file system to read from
** the mixfile, but think it is reading from a solitary file.
*/
if (!Pointer) {
long start = Start;
long length = Length;
/*
** This is a legitimate open to the file. All access to the file through this
** file object will be appropriately adjusted for mixfile support however. Also
** note that the filename attached to this object is NOT the same as the file
** attached to the file handle.
*/
char const * dupfile = strdup(File_Name());
Open(mixfile->Filename, READ);
Searching(false); // Disable multi-drive search.
Set_Name(dupfile);
free((void *)dupfile);
Start = start;
Length = length;
FromDisk = true;
}
} else {
/*
** The file cannot be found in any mixfile, so it must reside as
** an individual file on the disk. Or else it is just plain missing.
*/
return(CDFileClass::Open(rights));
}
return(true);
}
/***********************************************************************************
** Backward compatibility section.
*/
//extern "C" {
static CCFileClass Handles[10];
#ifdef NEVER
bool __cdecl Set_Search_Drives(BYTE const *)
{
CCFileClass::Set_Search_Path(path);
return(true);
}
#endif
WORD __cdecl Open_File(BYTE const *file_name, WORD mode)
{
for (int index = 0; index < sizeof(Handles)/sizeof(Handles[0]); index++) {
if (!Handles[index].Is_Open()) {
if (Handles[index].Open(file_name, mode)) {
return(index);
}
break;
}
}
return(ERROR);
}
VOID __cdecl Close_File(WORD handle)
{
if (handle != ERROR && Handles[handle].Is_Open()) {
Handles[handle].Close();
}
}
LONG __cdecl Read_File(WORD handle, VOID *buf, ULONG bytes)
{
if (handle != ERROR && Handles[handle].Is_Open()) {
return(Handles[handle].Read(buf, bytes));
}
return(0);
}
LONG __cdecl Write_File(WORD handle, VOID const *buf, ULONG bytes)
{
if (handle != ERROR && Handles[handle].Is_Open()) {
return(Handles[handle].Write(buf, bytes));
}
return(0);
}
WORD __cdecl Find_File(BYTE const *file_name)
{
CCFileClass file(file_name);
return(file.Is_Available());
}
#ifdef NEVER
WORD __cdecl Delete_File(BYTE const *file_name)
{
return(CCFileClass(file_name).Delete());
}
WORD __cdecl Create_File(BYTE const *file_name)
{
return(CCFileClass(file_name).Create());
}
ULONG __cdecl Load_Data(BYTE const *name, VOID *ptr, ULONG size)
{
return(CCFileClass(name).Read(ptr, size));
}
#endif
VOID * __cdecl Load_Alloc_Data(BYTE const *name, WORD )
{
CCFileClass file(name);
return(Load_Alloc_Data(file));
}
ULONG __cdecl File_Size(WORD handle)
{
if (handle != ERROR && Handles[handle].Is_Open()) {
return(Handles[handle].Size());
}
return(0);
}
#ifdef NEVER
ULONG __cdecl Write_Data(BYTE const *name, VOID const *ptr, ULONG size)
{
return(CCFileClass(name).Write(ptr, size));
}
#endif
ULONG __cdecl Seek_File(WORD handle, LONG offset, WORD starting)
{
if (handle != ERROR && Handles[handle].Is_Open()) {
return(Handles[handle].Seek(offset, starting));
}
return(0);
}
#ifdef NEVER
bool __cdecl Multi_Drive_Search(bool on)
{
// return(CCFileClass::Multi_Drive_Search(on));
return(on);
}
VOID __cdecl WWDOS_Init(VOID)
{
}
VOID __cdecl WWDOS_Shutdown(VOID)
{
}
WORD __cdecl Find_Disk_Number(BYTE const *)
{
return(0);
}
#endif
//ULONG cdecl Load_Uncompress(BYTE const *file, BuffType uncomp_buff, BuffType dest_buff, VOID *reserved_data)
//{
// return(Load_Uncompress(CCFileClass(file), uncomp_buff, dest_buff, reserved_data));
// return(CCFileClass(file).Load_Uncompress(uncomp_buff, dest_buff, reserved_data));
//}
extern "C" {
int MaxDevice;
int DefaultDrive;
char CallingDOSInt;
}
void Unfragment_File_Cache(void)
{
}

260
WIN32LIB/RAWFILE/FILE.H Normal file
View File

@@ -0,0 +1,260 @@
/*
** Command & Conquer Red Alert(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***************************************************************************
** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
***************************************************************************
* *
* Project Name : Library - Filio header stuff. *
* *
* File Name : FILE.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : September 13, 1993 *
* *
* Last Update : April 11, 1994 *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef FILE_H
#define FILE_H
#ifndef FILETEMP_H
// This should be removed once the library is all intacked.
#include "filetemp.h"
#endif
/*=========================================================================*/
/* File IO system defines and enumerations */
/*=========================================================================*/
#define XMAXPATH 80
/*
** These are the Open_File, Read_File, and Seek_File constants.
*/
#ifndef READ
#define READ 1 // Read access.
#endif
#ifndef WRITE
#define WRITE 2 // Write access.
#endif
#ifndef SEEK_SET
#define SEEK_SET 0 // Seek from start of file.
#define SEEK_CUR 1 // Seek relative from current location.
#define SEEK_END 2 // Seek from end of file.
#endif
typedef enum {
FILEB_PROCESSED=8,// Was the packed file header of this file processed?
FILEB_PRELOAD, // Scan for and make file resident at WWDOS_Init time?
FILEB_RESIDENT, // Make resident at Open_File time?
FILEB_FLUSH, // Un-resident at Close_File time?
FILEB_PACKED, // Is this file packed?
FILEB_KEEP, // Don't ever flush this resident file?
FILEB_PRIORITY, // Flush this file last?
FILEB_LAST
} FileFlags_Type;
#define FILEF_NONE 0
#define FILEF_PROCESSED (1<<FILEB_PROCESSED)
#define FILEF_PRELOAD (1<<FILEB_PRELOAD)
#define FILEF_RESIDENT (1<<FILEB_RESIDENT)
#define FILEF_FLUSH (1<<FILEB_FLUSH)
#define FILEF_PACKED (1<<FILEB_PACKED)
#define FILEF_KEEP (1<<FILEB_KEEP)
#define FILEF_PRIORITY (1<<FILEB_PRIORITY)
/*
** These errors are returned by WWDOS_Init(). All errors encountered are
** or'd together so there may be more then one error returned. Not all
** errors are fatal, such as the cache errors.
*/
typedef enum {
FI_SUCCESS = 0x00,
FI_CACHE_TOO_BIG = 0x01,
FI_CACHE_ALREADY_INIT = 0x02,
FI_FILEDATA_FILE_NOT_FOUND = 0x04,
FI_FILEDATA_TOO_BIG = 0x08,
FI_SEARCH_PATH_NOT_FOUND = 0x10,
FI_STARTUP_PATH_NOT_FOUND = 0x20,
FI_NO_CACHE_FOR_PRELOAD = 0x40,
FI_FILETABLE_NOT_INIT = 0x80,
} FileInitErrorType;
/*
** These are the errors that are detected by the File I/O system and
** passed to the io error routine.
*/
//lint -strong(AJX,FileErrorType)
typedef enum {
CANT_CREATE_FILE,
BAD_OPEN_MODE,
COULD_NOT_OPEN,
TOO_MANY_FILES,
CLOSING_NON_HANDLE,
READING_NON_HANDLE,
WRITING_NON_HANDLE,
SEEKING_NON_HANDLE,
SEEKING_BAD_OFFSET,
WRITING_RESIDENT,
UNKNOWN_INDEX,
DID_NOT_CLOSE,
FATAL_ERROR,
FILE_NOT_LISTED,
FILE_LENGTH_MISMATCH,
INTERNAL_ERROR,
MAKE_RESIDENT_ZERO_SIZE,
RESIDENT_SORT_FAILURE,
NUMBER_OF_ERRORS /* MAKE SURE THIS IS THE LAST ENTRY */
} FileErrorType;
// This is here tempararaly until library is put together.
//extern WORD __cdecl ( __cdecl IO_Error)(FileErrorType error, BYTE const *filename);
extern short (*Open_Error)(FileErrorType, BYTE const *);
/*=========================================================================*/
/* File IO system structures */
/*=========================================================================*/
//lint -strong(AJX,FileDataType)
typedef struct {
char *Name; // File name (include sub-directory but not volume).
long Size; // File size (0=indeterminate).
void *Ptr; // Resident file pointer.
long Start; // Starting offset in DOS handle file.
unsigned char Disk; // Disk number location.
unsigned char OpenCount; // Count of open locks on resident file.
unsigned short Flag; // File control flags.
} FileDataType;
/*=========================================================================*/
/* FIle IO system globals. */
/*=========================================================================*/
// These are cpp errors in funtions declarations JULIO JEREZ
// extern FileDataType __cdecl FileData[];
// extern BYTE __cdecl ExecPath[XMAXPATH + 1];
// extern BYTE __cdecl DataPath[XMAXPATH + 1];
// extern BYTE __cdecl StartPath[XMAXPATH + 1];
// extern BOOL __cdecl UseCD;
// The correct syntax is NO TYPE MODIFIER APPLY TO DATA DECLARATIONS
extern FileDataType FileData[];
extern char ExecPath[XMAXPATH + 1];
extern char DataPath[XMAXPATH + 1];
extern char StartPath[XMAXPATH + 1];
extern BOOL UseCD;
/*=========================================================================*/
/* The following prototypes are for the file: FILEINIT.CPP */
/*=========================================================================*/
void __cdecl WWDOS_Shutdown(void);
FileInitErrorType __cdecl WWDOS_Init(unsigned long cachesize, char *filedata, char *cdpath);
/*=========================================================================*/
/* The following prototypes are for the file: FILE.CPP */
/*=========================================================================*/
int __cdecl Open_File(char const *file_name, int mode);
void __cdecl Close_File(int handle);
long __cdecl Read_File(int handle, void *buf, unsigned long bytes);
int __cdecl Load_File ( const char *file_name , void *load_addr);
long __cdecl Write_File(int handle, void const *buf, unsigned long bytes);
unsigned long __cdecl Seek_File(int handle, long offset, int starting);
int __cdecl File_Exists(char const *file_name);
unsigned long __cdecl File_Size(int handle);
BOOL __cdecl Is_Handle_Valid(int handle, FileErrorType error, char const *name);
int __cdecl Open_File_With_Recovery( char const *file_name, unsigned int mode );
/*=========================================================================*/
/* The following prototypes are for the file: FILECACH.CPP */
/*=========================================================================*/
void Unfragment_File_Cache(void);
BOOL __cdecl Make_File_Resident(char const *filename);
int __cdecl Flush_Unused_File_Cache(int flush_keeps);
BOOL __cdecl Free_Resident_File(char const *file);
/*=========================================================================*/
/* The following prototypes are for the file: FILECHNG.CPP */
/*=========================================================================*/
int __cdecl Create_File(char const *file_name);
int __cdecl Delete_File(char const *file_name);
BOOL __cdecl Change_File_Size(int handle, unsigned long new_size);
/*=========================================================================*/
/* The following prototypes are for the file: FILEINFO.CPP */
/*=========================================================================*/
int __cdecl Get_DOS_Handle(int fh);
int __cdecl Free_Handles(void);
int __cdecl Find_Disk_Number(char const *file_name);
int __cdecl Set_File_Flags(char const *filename, int flags);
int __cdecl Clear_File_Flags(char const *filename, int flags);
int __cdecl Get_File_Flags(char const *filename);
BOOL __cdecl Multi_Drive_Search(BOOL on);
/*=========================================================================*/
/* The following prototypes are for the file: FINDFILE.CPP */
/*=========================================================================*/
int __cdecl Find_File(char const *file_name);
int __cdecl Find_File_Index(char const *filename);
/*=========================================================================*/
/* The following prototypes are for the file: FFIRST.ASM */
/*=========================================================================*/
#include <dos.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int __cdecl Find_First(unsigned char *fname, unsigned int mode, struct find_t *ffblk);
extern int __cdecl Find_Next(struct find_t *ffblk);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,61 @@
/*
** Command & Conquer Red Alert(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***************************************************************************
** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
***************************************************************************
* *
* Project Name : Temp header for file routines. *
* *
* File Name : FILETEMP.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : April 20, 1994 *
* *
* Last Update : April 20, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef FILETEMP_H
#define FILETEMP_H
/////////////////////////////////////////////////////////////////////
// THIS DOES NOT BELONG HERE. IT WAS PUT HERE JUST TO GET THE THING
// TO COMPILE. ONCE THE BUFFER AND PAGE SYSTEMS ARE PUT IN, THESE
// WILL NEED TO BE TAKEN OUT AND MODS MADE TO ANY FUNCTION USING BuffType.
// SKB 4/20/94.
/*=========================================================================*/
/* Defines and such that must go into wwstd.h */
/*=========================================================================*/
// Look at FileErrorType below for the IO_Error function.
//extern WORD __cdecl ( __cdecl IO_Error)(FileErrorType error, BYTE const *filename);
VOID __cdecl Prog_End(VOID);
extern WORD Hard_Error_Occured;
//////////////////////// END OF DON'T BELONG //////////////////////////////////
#endif //FILETEMP_H

179
WIN32LIB/RAWFILE/MAKEFILE Normal file
View File

@@ -0,0 +1,179 @@
#
# Command & Conquer Red Alert(tm)
# Copyright 2025 Electronic Arts Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************
#** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
#***************************************************************************
#* *
#* Project Name : Westwood Library .LIB makefile *
#* *
#* File Name : MAKEFILE *
#* *
#* Programmer : Julio R. Jerez *
#* *
#* Start Date : Jan 26, 1995 *
#* *
#* *
#*-------------------------------------------------------------------------*
#* *
#* Required environment variables: *
#* WIN32LIB = your root WIN32LIB path *
#* WIN32VCS = root directory for wwlib version control archive *
#* COMPILER = your Watcom installation path *
#* *
#* Required changes to makefile: *
#* PROJ_NAME = name of the library you're building *
#* OBJECTS = list of objects in your library *
#* *
#* Optional changes to makefile: *
#* PROJ_DIR = full pathname of your working directory *
#* .path.xxx = full pathname where various file types live *
#* *
#***************************************************************************
#---------------------------------------------------------------------------
# Verify user's environment
#---------------------------------------------------------------------------
!ifndef %WIN32LIB
!error WIN32LIB Environment var not configured.
!endif
!ifndef %WIN32VCS
!error WIN32VCS Environment var not configured.
!endif
!ifndef %WATCOM
!error WATCOM Environment var not configured.
!endif
#===========================================================================
# User-defined section: the user should tailor this section for each project
#===========================================================================
PROJ_NAME = rawfile
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
LIB_DIR = $(%WIN32LIB)\lib
!include $(%WIN32LIB)\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = &
rawfile.obj
#---------------------------------------------------------------------------
# Path macros: one path for each file type.
# These paths are used to tell make where to find/put each file type.
#---------------------------------------------------------------------------
.asm: $(PROJ_DIR)
.c: $(PROJ_DIR)
.cpp: $(PROJ_DIR)
.h: $(PROJ_DIR)
.obj: $(PROJ_DIR)
.lib: $(WWLIB)\lib
.exe: $(PROJ_DIR)
#===========================================================================
# Pre-defined section: there should be little need to modify this section.
#===========================================================================
#---------------------------------------------------------------------------
# Tools/commands
#---------------------------------------------------------------------------
C_CMD = wcc386
CPP_CMD = wpp386
LIB_CMD = wlib
LINK_CMD = wlink
ASM_CMD = tasm
#---------------------------------------------------------------------------
# Include & library paths
# If LIB & INCLUDE are already defined, they are used in addition to the
# WWLIB32 lib & include; otherwise, they're constructed from
# BCDIR & TNTDIR
#---------------------------------------------------------------------------
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB
INCLUDEPATH = $(%WIN32LIB)\INCLUDE;$(%WATCOM)\H
#---------------------------------------------------------------------------
# Implicit rules
# Compiler:
# ($< = full dependent with path)
# Assembler:
# output obj's are constructed from .obj: & the $& macro
# ($< = full dependent with path)
# tasm's cfg file is not invoked as a response file.
#---------------------------------------------------------------------------
.c.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
*$(C_CMD) $(CC_CFG) $<
.cpp.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
*$(CPP_CMD) $(CC_CFG) $(PROJ_DIR)\$^*.cpp
.asm.obj: $(%WIN32LIB)\project.cfg
$(ASM_CMD) $(ASM_CFG) $<
#---------------------------------------------------------------------------
# Default target: configuration files & library (in that order)
#---------------------------------------------------------------------------
all: $(LIB_DIR)\$(PROJ_NAME).lib .SYMBOLIC
#---------------------------------------------------------------------------
# Build the library
# The original library is deleted by the librarian
# Lib objects & -+ commands are constructed by substituting within the
# $^@ macro (which expands to all target dependents, separated with
# spaces)
# Tlib's cfg file is not invoked as a response file.
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
#---------------------------------------------------------------------------
$(LIB_DIR)\$(PROJ_NAME).lib: $(OBJECTS) objects.lbc
copy *.h $(%WIN32LIB)\include
copy *.inc $(%WIN32LIB)\include
copy *.cpp $(%WIN32LIB)\srcdebug
copy *.asm $(%WIN32LIB)\srcdebug
$(LIB_CMD) $(LIB_CFG) $^@ @objects.lbc
#---------------------------------------------------------------------------
# Objects now have a link file which is NOT generated everytime. Instead
# it just has its own dependacy rule.
#---------------------------------------------------------------------------
objects.lbc : $(OBJECTS)
%create $^@
for %index in ($(OBJECTS)) do %append $^@ +%index
#---------------------------------------------------------------------------
# Create the test directory and make it.
#---------------------------------------------------------------------------
test:
mkdir test
cd test
copy $(%WWVCS)\$(PROJ_NAME)\test\vcs.cfg
update
wmake
cd ..
#**************************** End of makefile ******************************

View File

@@ -0,0 +1,169 @@
#
# Command & Conquer Red Alert(tm)
# Copyright 2025 Electronic Arts Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************
#** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
#***************************************************************************
#* *
#* Project Name : Westwood Library .LIB makefile *
#* *
#* File Name : MAKEFILE *
#* *
#* Programmer : Julio R. Jerez *
#* *
#* Start Date : Jan 26, 1995 *
#* *
#* *
#*-------------------------------------------------------------------------*
#* *
#* Required environment variables: *
#* WIN32LIB = your root WWFLAT path *
#* WIN32VCS = root directory for wwlib version control archive *
#* COMPILER = your Watcom installation path *
#* *
#* Required changes to makefile: *
#* PROJ_NAME = name of the library you're building *
#* OBJECTS = list of objects in your library *
#* *
#* Optional changes to makefile: *
#* PROJ_DIR = full pathname of your working directory *
#* .path.xxx = full pathname where various file types live *
#* *
#***************************************************************************
.AUTODEPEND
#---------------------------------------------------------------------------
# Verify user's environment
#---------------------------------------------------------------------------
!ifndef WIN32LIB
!error WIN32LIB Environment var not configured.
!endif
!ifndef WIN32VCS
!error WIN32VCS Environment var not configured.
!endif
!ifndef COMPILER
!error COMPILER Environment var not configured.
!endif
#===========================================================================
# User-defined section: the user should tailor this section for each project
#===========================================================================
PROJ_NAME = rawfile
PROJ_DIR = $(WIN32LIB)\$(PROJ_NAME)
LIB_DIR = $(WIN32LIB)\lib
!include $(WIN32LIB)\\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = \
rawfile.obj
#---------------------------------------------------------------------------
# Path macros: one path for each file type.
# These paths are used to tell make where to find/put each file type.
#---------------------------------------------------------------------------
.path.asm = $(PROJ_DIR)
.path.c = $(PROJ_DIR)
.path.cpp = $(PROJ_DIR)
.path.h = $(PROJ_DIR)
.path.obj = $(PROJ_DIR)
.path.lib = $(WIN32LIB)\lib
.path.exe = $(PROJ_DIR)
#===========================================================================
# Pre-defined section: there should be little need to modify this section.
#===========================================================================
#---------------------------------------------------------------------------
# Tools/commands
#---------------------------------------------------------------------------
C_CMD = bcc32
CPP_CMD = bcc32
LIB_CMD = tlib
LINK_CMD = tlink32
ASM_CMD = tasm32
#---------------------------------------------------------------------------
# Include & library paths
# If LIB & INCLUDE are already defined, they are used in addition to the
# WWLIB32 lib & include; otherwise, they're constructed from
# BCDIR & TNTDIR
#---------------------------------------------------------------------------
LIBPATH = $(WIN32LIB)\LIB;$(COMPILER)\LIB
INCLUDEPATH = $(WIN32LIB)\INCLUDE;$(COMPILER)\INCLUDE
#---------------------------------------------------------------------------
# Implicit rules
# Compiler:
# ($< = full dependent with path)
# Assembler:
# output obj's are constructed from .obj: & the $& macro
# ($< = full dependent with path)
# tasm's cfg file is not invoked as a response file.
#---------------------------------------------------------------------------
.c.obj:
$(C_CMD) $(CC_CFG) $<
.cpp.obj:
$(CPP_CMD) $(CC_CFG) $<
.asm.obj:
$(ASM_CMD) $(ASM_CFG) $<
#---------------------------------------------------------------------------
# Default target: configuration files & library (in that order)
#---------------------------------------------------------------------------
all: $(LIB_DIR)\$(PROJ_NAME).lib
#---------------------------------------------------------------------------
# Build the library
# The original library is deleted by the librarian
# Lib objects & -+ commands are constructed by substituting within the
# $^@ macro (which expands to all target dependents, separated with
# spaces)
# Tlib's cfg file is not invoked as a response file.
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
#---------------------------------------------------------------------------
$(LIB_DIR)\\$(PROJ_NAME).lib: $(OBJECTS)
copy *.h $(WIN32LIB)\\include
copy *.inc $(WIN32LIB)\\include
copy *.cpp $(WIN32LIB)\\srcdebug
copy *.asm $(WIN32LIB)\\srcdebug
$(LIB_CMD) $< $(LIB_CFG) @&&|
-+rawfile
|
#---------------------------------------------------------------------------
# Create the test directory and make it.
#---------------------------------------------------------------------------
test:
mkdir test
cd test
copy $(WWVCS)\\$(PROJ_NAME)\test\vcs.cfg
update
wmake
cd ..

View File

@@ -0,0 +1,179 @@
#
# Command & Conquer Red Alert(tm)
# Copyright 2025 Electronic Arts Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************
#** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
#***************************************************************************
#* *
#* Project Name : Westwood Library .LIB makefile *
#* *
#* File Name : MAKEFILE *
#* *
#* Programmer : Julio R. Jerez *
#* *
#* Start Date : Jan 26, 1995 *
#* *
#* *
#*-------------------------------------------------------------------------*
#* *
#* Required environment variables: *
#* WIN32LIB = your root WIN32LIB path *
#* WIN32VCS = root directory for wwlib version control archive *
#* COMPILER = your Watcom installation path *
#* *
#* Required changes to makefile: *
#* PROJ_NAME = name of the library you're building *
#* OBJECTS = list of objects in your library *
#* *
#* Optional changes to makefile: *
#* PROJ_DIR = full pathname of your working directory *
#* .path.xxx = full pathname where various file types live *
#* *
#***************************************************************************
#---------------------------------------------------------------------------
# Verify user's environment
#---------------------------------------------------------------------------
!ifndef %WIN32LIB
!error WIN32LIB Environment var not configured.
!endif
!ifndef %WIN32VCS
!error WIN32VCS Environment var not configured.
!endif
!ifndef %WATCOM
!error WATCOM Environment var not configured.
!endif
#===========================================================================
# User-defined section: the user should tailor this section for each project
#===========================================================================
PROJ_NAME = rawfile
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
LIB_DIR = $(%WIN32LIB)\lib
!include $(%WIN32LIB)\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = &
rawfile.obj
#---------------------------------------------------------------------------
# Path macros: one path for each file type.
# These paths are used to tell make where to find/put each file type.
#---------------------------------------------------------------------------
.asm: $(PROJ_DIR)
.c: $(PROJ_DIR)
.cpp: $(PROJ_DIR)
.h: $(PROJ_DIR)
.obj: $(PROJ_DIR)
.lib: $(WWLIB)\lib
.exe: $(PROJ_DIR)
#===========================================================================
# Pre-defined section: there should be little need to modify this section.
#===========================================================================
#---------------------------------------------------------------------------
# Tools/commands
#---------------------------------------------------------------------------
C_CMD = wcc386
CPP_CMD = wpp386
LIB_CMD = wlib
LINK_CMD = wlink
ASM_CMD = tasm32
#---------------------------------------------------------------------------
# Include & library paths
# If LIB & INCLUDE are already defined, they are used in addition to the
# WWLIB32 lib & include; otherwise, they're constructed from
# BCDIR & TNTDIR
#---------------------------------------------------------------------------
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB
INCLUDEPATH = $(%WIN32LIB)\INCLUDE;$(%WATCOM)\H
#---------------------------------------------------------------------------
# Implicit rules
# Compiler:
# ($< = full dependent with path)
# Assembler:
# output obj's are constructed from .obj: & the $& macro
# ($< = full dependent with path)
# tasm's cfg file is not invoked as a response file.
#---------------------------------------------------------------------------
.c.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
$(C_CMD) $(CC_CFG) $<
.cpp.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
$(CPP_CMD) $(CC_CFG) $<
.asm.obj: $(%WIN32LIB)\project.cfg
$(ASM_CMD) $(ASM_CFG) $<
#---------------------------------------------------------------------------
# Default target: configuration files & library (in that order)
#---------------------------------------------------------------------------
all: $(LIB_DIR)\$(PROJ_NAME).lib .SYMBOLIC
#---------------------------------------------------------------------------
# Build the library
# The original library is deleted by the librarian
# Lib objects & -+ commands are constructed by substituting within the
# $^@ macro (which expands to all target dependents, separated with
# spaces)
# Tlib's cfg file is not invoked as a response file.
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
#---------------------------------------------------------------------------
$(LIB_DIR)\$(PROJ_NAME).lib: $(OBJECTS) objects.lbc
copy *.h $(%WIN32LIB)\include
copy *.inc $(%WIN32LIB)\include
copy *.cpp $(%WIN32LIB)\srcdebug
copy *.asm $(%WIN32LIB)\srcdebug
$(LIB_CMD) $(LIB_CFG) $^@ @objects.lbc
#---------------------------------------------------------------------------
# Objects now have a link file which is NOT generated everytime. Instead
# it just has its own dependacy rule.
#---------------------------------------------------------------------------
objects.lbc : $(OBJECTS)
%create $^@
for %index in ($(OBJECTS)) do %append $^@ +%index
#---------------------------------------------------------------------------
# Create the test directory and make it.
#---------------------------------------------------------------------------
test:
mkdir test
cd test
copy $(%WWVCS)\$(PROJ_NAME)\test\vcs.cfg
update
wmake
cd ..
#**************************** End of makefile ******************************

1303
WIN32LIB/RAWFILE/RAWFILE.CPP Normal file

File diff suppressed because it is too large Load Diff

255
WIN32LIB/RAWFILE/RAWFILE.H Normal file
View File

@@ -0,0 +1,255 @@
/*
** Command & Conquer Red Alert(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\rawfile.h_v 2.15 06 Sep 1995 16:29:30 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Westwood Library *
* *
* File Name : RAWFILE.H *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : August 8, 1994 *
* *
* Last Update : October 18, 1994 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* RawFileClass::File_Name -- Returns with the filename associate with the file object. *
* RawFileClass::RawFileClass -- Default constructor for a file object. *
* RawFileClass::Is_Open -- Checks to see if the file is open or not. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef RAWFILE_H
#define RAWFILE_H
#define WIN32 1
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
#define _WIN32
#endif // _WIN32
#include <windows.h>
//#include <wwlib32.h>
#include <limits.h>
#include <errno.h>
#include <windows.h>
//#include <algo.h>
#include "wwfile.h"
#ifdef NEVER
/*
** This is a duplicate of the error numbers. The error handler for the RawFileClass handles
** these errors. If the error routine is overridden and additional errors are defined, then
** use numbers starting with 100. Note that these errors here are listed in numerical order.
** These errors are defined in the standard header file "ERRNO.H".
*/
EZERO, // Non-error.
EINVFNC, // Invalid function number.
ENOFILE, // File not found.
ENOENT=ENOFILE, // No such file or directory.
ENOPATH, // Path not found.
EMFILE, // Too many open files.
EACCES, // Permission denied.
EBADF, // Bad file number.
ECONTR, // Memory blocks destroyed.
ENOMEM, // Not enough core memory.
EINVMEM, // Invalid memory block address.
EINVENV, // Invalid environment.
EINVFMT, // Invalid format.
EINVACC, // Invalid access code.
EINVDAT, // Invalid data.
EFAULT, // Unknown error.
EINVDRV, // Invalid drive specified.
ENODEV=EINVDRV, // No such device.
ECURDIR, // Attempt to remove CurDir.
ENOTSAM, // Not same device.
ENMFILE, // No more files.
EINVAL, // Invalid argument.
E2BIG, // Argument list too long.
ENOEXEC, // exec format error.
EXDEV, // Cross-device link.
ENFILE, // Too many open files.
ECHILD, // No child process.
ENOTTY, // not used
ETXTBSY, // not used
EFBIG, // not used
ENOSPC, // No space left on device.
ESPIPE, // Illegal seek.
EROFS, // Read-only file system.
EMLINK, // not used
EPIPE, // Broken pipe.
EDOM, // Math argument.
ERANGE, // Result too large.
EEXIST, // File already exists.
EDEADLOCK, // Locking violation.
EPERM, // Operation not permitted.
ESRCH, // not used
EINTR, // Interrupted function call.
EIO, // Input/output error.
ENXIO, // No such device or address.
EAGAIN, // Resource temporarily unavailable.
ENOTBLK, // not used
EBUSY, // Resource busy.
ENOTDIR, // not used
EISDIR, // not used
EUCLEAN, // not used
#endif
/*
** This is the definition of the raw file class. It is derived from the abstract base FileClass
** and handles the interface to the low level DOS routines. This is the first class in the
** chain of derived file classes that actually performs a useful function. With this class,
** I/O is possible. More sophisticated features, such as packed files, CD-ROM support,
** file caching, and XMS/EMS memory support, are handled by derived classes.
**
** Of particular importance is the need to override the error routine if more sophisticated
** error handling is required. This is more than likely if greater functionality is derived
** from this base class.
*/
class RawFileClass : public FileClass
{
public:
/*
** This is a record of the access rights used to open the file. These rights are
** used if the file object is duplicated.
*/
int Rights;
RawFileClass(char const *filename);
RawFileClass(void);
RawFileClass (RawFileClass const & f);
RawFileClass & operator = (RawFileClass const & f);
virtual ~RawFileClass(void) {if (Allocated && Filename) free((char *)Filename);};
virtual char const * File_Name(void) const;
virtual char const * Set_Name(char const *filename);
virtual int Create(void);
virtual int Delete(void);
virtual int Is_Available(int forced=false);
virtual int Is_Open(void) const;
virtual int Open(char const *filename, int rights=READ);
virtual int Open(int rights=READ);
virtual long Read(void *buffer, long size);
virtual long Seek(long pos, int dir=SEEK_CUR);
virtual long Size(void);
virtual long Write(void const *buffer, long size);
virtual void Close(void);
virtual void Error(int error, int canretry = false, char const * filename=NULL);
virtual void Set_Buffer_Size(int size);
protected:
/*
** This function returns the largest size a low level DOS read or write may
** perform. Larger file transfers are performed in chunks of this size or less.
*/
long Transfer_Block_Size(void) {return (long)((unsigned)UINT_MAX)-16L;};
private:
/*
** This is the low level DOS handle. A -1 indicates an empty condition.
*/
int Handle;
/*
** This points to the filename as a NULL terminated string. It may point to either a
** constant or an allocated string as indicated by the "Allocated" flag.
*/
char const * const Filename;
/*
** Filenames that were assigned as part of the construction process
** are not allocated. It is assumed that the filename string is a
** constant in that case and thus making duplication unnecessary.
** This value will be non-zero if the filename has be allocated
** (using strdup()).
*/
unsigned Allocated:1;
};
/***********************************************************************************************
* RawFileClass::File_Name -- Returns with the filename associate with the file object. *
* *
* Use this routine to determine what filename is associated with this file object. If no *
* filename has yet been assigned, then this routing will return NULL. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with a pointer to the file name associated with this file object or NULL *
* if one doesn't exist. *
* *
* WARNINGS: none *
* *
* HISTORY: *
;* 10/18/1994 JLB : Created. *
*=============================================================================================*/
inline char const * RawFileClass::File_Name(void) const
{
return Filename;
}
/***********************************************************************************************
* RawFileClass::RawFileClass -- Default constructor for a file object. *
* *
* This constructs a null file object. A null file object has no file handle or filename *
* associated with it. In order to use a file object created in this fashion it must be *
* assigned a name and then opened. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
;* 10/18/1994 JLB : Created. *
*=============================================================================================*/
inline RawFileClass::RawFileClass(void) : Filename(0)
{
Handle = -1;
Allocated = false;
}
/***********************************************************************************************
* RawFileClass::Is_Open -- Checks to see if the file is open or not. *
* *
* Use this routine to determine if the file is open. It returns true if it is. *
* *
* INPUT: none *
* *
* OUTPUT: bool; Is the file open? *
* *
* *
* WARNINGS: none *
* *
* HISTORY: *
;* 10/18/1994 JLB : Created. *
*=============================================================================================*/
inline int RawFileClass::Is_Open(void) const
{
return (Handle != -1);
}
#endif

71
WIN32LIB/RAWFILE/WWFILE.H Normal file
View File

@@ -0,0 +1,71 @@
/*
** Command & Conquer Red Alert(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\wwfile.h_v 2.14 06 Sep 1995 16:30:00 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Westwood Library *
* *
* File Name : WWFILE.H *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : August 8, 1994 *
* *
* Last Update : August 8, 1994 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef WWFILE_H
#define WWFILE_H
#include <stdio.h>
#ifndef READ
#define READ _READ
#endif
#ifndef WRITE
#define WRITE _WRITE
#endif
class FileClass
{
public:
virtual ~FileClass(void) {};
virtual char const * File_Name(void) const = 0;
virtual char const * Set_Name(char const *filename) = 0;
virtual int Create(void) = 0;
virtual int Delete(void) = 0;
virtual int Is_Available(int forced=false) = 0;
virtual int Is_Open(void) const = 0;
virtual int Open(char const *filename, int rights=READ) = 0;
virtual int Open(int rights=READ) = 0;
virtual long Read(void *buffer, long size) = 0;
virtual long Seek(long pos, int dir=SEEK_CUR) = 0;
virtual long Size(void) = 0;
virtual long Write(void const *buffer, long size) = 0;
virtual void Close(void) = 0;
operator char const * () {return File_Name();};
};
#endif