Skip to content

Commit cbb2b40

Browse files
feliwirFighter19d10sfan
authored
[ZH][LINUX] Add C++ 17 based filesystem implementation (#693)
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com> Co-authored-by: d10sfan <4337981+d10sfan@users.noreply.github.com>
1 parent 63bd300 commit cbb2b40

File tree

10 files changed

+1005
-0
lines changed

10 files changed

+1005
-0
lines changed

GeneralsMD/Code/GameEngine/Source/Common/System/MemoryInit.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ static PoolSizeRec sizes[] =
556556
{ "AttackPriorityInfo", 32, 32 },
557557
{ "SequentialScript", 32, 32 },
558558
{ "Win32LocalFile", 1024, 256 },
559+
{ "StdLocalFile", 1024, 256 },
559560
{ "RAMFile", 32, 32 },
560561
{ "BattlePlanBonuses", 32, 32 },
561562
{ "KindOfPercentProductionChange", 32, 32 },

GeneralsMD/Code/GameEngineDevice/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,20 @@ set(GAMEENGINEDEVICE_SRC
194194
Source/Win32Device/GameClient/Win32Mouse.cpp
195195
)
196196

197+
# Add C++ 17 FileSystem implementation for non-VS6 builds
198+
if(NOT IS_VS6_BUILD)
199+
list(APPEND GAMEENGINEDEVICE_SRC
200+
Include/StdDevice/Common/StdBIGFile.h
201+
Include/StdDevice/Common/StdBIGFileSystem.h
202+
Include/StdDevice/Common/StdLocalFile.h
203+
Include/StdDevice/Common/StdLocalFileSystem.h
204+
Source/StdDevice/Common/StdBIGFile.cpp
205+
Source/StdDevice/Common/StdBIGFileSystem.cpp
206+
Source/StdDevice/Common/StdLocalFile.cpp
207+
Source/StdDevice/Common/StdLocalFileSystem.cpp
208+
)
209+
endif()
210+
197211
add_library(z_gameenginedevice STATIC)
198212

199213
target_sources(z_gameenginedevice PRIVATE ${GAMEENGINEDEVICE_SRC})
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
/////// StdBIGFile.h ////////////////////////////////////
26+
// Stephan Vedder, April 2025
27+
///////////////////////////////////////////////////////////
28+
29+
#pragma once
30+
31+
#ifndef __STDBIGFILE_H
32+
#define __STDBIGFILE_H
33+
34+
#include "Common/ArchiveFile.h"
35+
#include "Common/AsciiString.h"
36+
#include "Common/List.h"
37+
38+
class StdBIGFile : public ArchiveFile
39+
{
40+
public:
41+
StdBIGFile();
42+
virtual ~StdBIGFile();
43+
44+
virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; ///< fill in the fileInfo struct with info about the requested file.
45+
virtual File* openFile( const Char *filename, Int access = 0 );///< Open the specified file within the BIG file
46+
virtual void closeAllFiles( void ); ///< Close all file opened in this BIG file
47+
virtual AsciiString getName( void ); ///< Returns the name of the BIG file
48+
virtual AsciiString getPath( void ); ///< Returns full path and name of BIG file
49+
virtual void setSearchPriority( Int new_priority ); ///< Set this BIG file's search priority
50+
virtual void close( void ); ///< Close this BIG file
51+
52+
protected:
53+
54+
AsciiString m_name; ///< BIG file name
55+
AsciiString m_path; ///< BIG file path
56+
};
57+
58+
#endif // __STDBIGFILE_H
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
//////// StdBIGFileSystem.h ///////////////////////////
26+
// Stephan Vedder, April 2025
27+
/////////////////////////////////////////////////////////////
28+
29+
#pragma once
30+
31+
#ifndef __STDBIGFILESYSTEM_H
32+
#define __STDBIGFILESYSTEM_H
33+
34+
#include "Common/ArchiveFileSystem.h"
35+
36+
class StdBIGFileSystem : public ArchiveFileSystem
37+
{
38+
public:
39+
StdBIGFileSystem();
40+
virtual ~StdBIGFileSystem();
41+
42+
virtual void init( void );
43+
virtual void update( void );
44+
virtual void reset( void );
45+
virtual void postProcessLoad( void );
46+
47+
// ArchiveFile operations
48+
virtual void closeAllArchiveFiles( void ); ///< Close all Archivefiles currently open
49+
50+
// File operations
51+
virtual ArchiveFile * openArchiveFile(const Char *filename);
52+
virtual void closeArchiveFile(const Char *filename);
53+
virtual void closeAllFiles( void ); ///< Close all files associated with ArchiveFiles
54+
55+
virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE);
56+
protected:
57+
58+
};
59+
60+
#endif // __STDBIGFILESYSTEM_H
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
///// StdLocalFile.h ///////////////////////////
26+
// Stephan Vedder, April 2025
27+
//////////////////////////////////////////////////
28+
29+
#pragma once
30+
31+
#ifndef __STDLOCALFILE_H
32+
#define __STDLOCALFILE_H
33+
34+
#include "Common/LocalFile.h"
35+
36+
class StdLocalFile : public LocalFile
37+
{
38+
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(StdLocalFile, "StdLocalFile")
39+
public:
40+
StdLocalFile();
41+
//virtual ~StdLocalFile();
42+
43+
protected:
44+
};
45+
46+
#endif // __STDLOCALFILE_H
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
///// StdLocalFileSystem.h //////////////////////////////////
26+
// Stephan Vedder, April 2025
27+
///////////////////////////////////////////////////////////////
28+
29+
#pragma once
30+
31+
#ifndef __STDLOCALFILESYSTEM_H
32+
#define __STDLOCALFILESYSTEM_H
33+
#include "Common/LocalFileSystem.h"
34+
35+
class StdLocalFileSystem : public LocalFileSystem
36+
{
37+
public:
38+
StdLocalFileSystem();
39+
virtual ~StdLocalFileSystem();
40+
41+
virtual void init();
42+
virtual void reset();
43+
virtual void update();
44+
45+
virtual File * openFile(const Char *filename, Int access = 0); ///< open the given file.
46+
virtual Bool doesFileExist(const Char *filename) const; ///< does the given file exist?
47+
48+
virtual void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories.
49+
virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const;
50+
51+
virtual Bool createDirectory(AsciiString directory);
52+
53+
protected:
54+
};
55+
56+
#endif // __STDLOCALFILESYSTEM_H

0 commit comments

Comments
 (0)