Skip to content

Commit ee69c76

Browse files
committed
cage archive
1 parent 0abad94 commit ee69c76

File tree

21 files changed

+1475
-144
lines changed

21 files changed

+1475
-144
lines changed

cmake/cage_assets.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
set(cage_assets_current_list_dir "${CMAKE_CURRENT_LIST_DIR}")
3-
set(cage_assets_destination_path "${CMAKE_BINARY_DIR}/result/assets.zip" CACHE FILEPATH "Where to save the final archive with all assets.")
3+
set(cage_assets_destination_path "${CMAKE_BINARY_DIR}/result/assets.carch" CACHE FILEPATH "Where to save the final archive with all assets.")
44
set(cage_assets_intermediate_path "${CMAKE_BINARY_DIR}/result/data" CACHE PATH "Directory for assets processing and database.")
55

66
function(cage_assets_generate_config)

sources/asset-database/databank.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void checkOutputDir()
350350
{
351351
const PathTypeFlags t = pathType(configPathOutput);
352352
if (configOutputArchive && any(t & PathTypeFlags::NotFound))
353-
return pathCreateArchive(configPathOutput);
353+
return pathCreateArchiveCarch(configPathOutput);
354354
if (any(t & PathTypeFlags::Archive))
355355
return;
356356
// the output is not an archive, output to it directly

sources/include/cage-core/assetsManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace cage
6969

7070
struct CAGE_CORE_API AssetManagerCreateConfig
7171
{
72-
String assetsFolderName = "assets.zip";
72+
String assetsFolderName = "assets.carch";
7373
uint32 diskLoadingThreads = 2;
7474
uint32 customProcessingThreads = 5;
7575
uint32 schemesMaxCount = 100; // 0..49 for engine and 50..99 for the game

sources/include/cage-core/files.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ namespace cage
6464
virtual ~File() = default;
6565
};
6666

67-
CAGE_CORE_API Holder<File> newFile(const String &path, const FileMode &mode);
67+
CAGE_CORE_API Holder<File> newFile(const String &path, FileMode mode);
6868
CAGE_CORE_API Holder<File> readFile(const String &path);
6969
CAGE_CORE_API Holder<File> writeFile(const String &path);
7070
CAGE_CORE_API Holder<File> newFileBuffer(Holder<PointerRange<const char>> buffer);
71-
CAGE_CORE_API Holder<File> newFileBuffer(Holder<PointerRange<char>> buffer, const FileMode &mode = FileMode(true, false));
71+
CAGE_CORE_API Holder<File> newFileBuffer(Holder<PointerRange<char>> buffer, FileMode mode = FileMode(true, false));
7272
CAGE_CORE_API Holder<File> newFileBuffer(Holder<const MemoryBuffer> buffer);
73-
CAGE_CORE_API Holder<File> newFileBuffer(Holder<MemoryBuffer> buffer, const FileMode &mode = FileMode(true, true));
74-
CAGE_CORE_API Holder<File> newFileBuffer(MemoryBuffer &&buffer, const FileMode &mode = FileMode(true, true));
73+
CAGE_CORE_API Holder<File> newFileBuffer(Holder<MemoryBuffer> buffer, FileMode mode = FileMode(true, true));
74+
CAGE_CORE_API Holder<File> newFileBuffer(MemoryBuffer &&buffer, FileMode mode = FileMode(true, true));
7575
CAGE_CORE_API Holder<File> newFileBuffer();
7676

7777
// receive operating system issued notifications about filesystem changes
@@ -136,7 +136,8 @@ namespace cage
136136
CAGE_CORE_API void pathCreateDirectories(const String &path);
137137

138138
// create an empty archive at the specified path, it can be populated afterwards
139-
CAGE_CORE_API void pathCreateArchive(const String &path, const String &options = "");
139+
CAGE_CORE_API void pathCreateArchiveZip(const String &path);
140+
CAGE_CORE_API void pathCreateArchiveCarch(const String &path);
140141

141142
// moves (renames) or copies a file or directory
142143
CAGE_CORE_API void pathMove(const String &from, const String &to);

sources/libcore/filesystem/abstractFiles.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44

55
#include "files.h"
66

7-
#include <cage-core/concurrent.h>
87
#include <cage-core/debug.h>
9-
#include <cage-core/memoryBuffer.h>
108
#include <cage-core/pointerRangeHolder.h>
119
#include <cage-core/stdHash.h>
1210
#include <cage-core/string.h>
1311

1412
namespace cage
1513
{
16-
std::shared_ptr<ArchiveAbstract> archiveOpenZipTry(Holder<File> &&f);
14+
std::shared_ptr<ArchiveAbstract> archiveOpenZipTry(Holder<File> f);
15+
std::shared_ptr<ArchiveAbstract> archiveOpenCarchTry(Holder<File> f);
1716
std::shared_ptr<ArchiveAbstract> archiveOpenReal(const String &path);
1817

1918
namespace
@@ -73,7 +72,10 @@ namespace cage
7372
{
7473
CAGE_ASSERT(parent);
7574
const String inPath = pathToRel(fullPath, parent->myPath);
76-
return archiveOpenZipTry(parent->openFile(inPath, FileMode(true, false)));
75+
Holder<File> f = parent->openFile(inPath, FileMode(true, false));
76+
if (auto cap = archiveOpenCarchTry(f.share()))
77+
return cap;
78+
return archiveOpenZipTry(f.share());
7779
}
7880

7981
void walkRight(String &p, String &i)

sources/libcore/filesystem/api.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#include "files.h"
22

3-
#include <cage-core/concurrent.h>
43
#include <cage-core/debug.h>
54
#include <cage-core/lineReader.h>
65
#include <cage-core/math.h> // min
7-
#include <cage-core/memoryBuffer.h>
86
#include <cage-core/pointerRangeHolder.h>
97
#include <cage-core/string.h>
108

119
namespace cage
1210
{
13-
void archiveCreateZip(const String &path, const String &options);
11+
void archiveCreateZip(const String &path);
12+
void archiveCreateCarch(const String &path);
1413

1514
bool FileMode::valid() const
1615
{
@@ -134,7 +133,7 @@ namespace cage
134133
CAGE_THROW_CRITICAL(Exception, "calling mode on an abstract file");
135134
}
136135

137-
Holder<File> newFile(const String &path, const FileMode &mode)
136+
Holder<File> newFile(const String &path, FileMode mode)
138137
{
139138
ScopeLock lock(fsMutex());
140139
auto [a, p] = archiveFindTowardsRoot(path, ArchiveFindModeEnum::FileExclusive);
@@ -267,15 +266,26 @@ namespace cage
267266
a->createDirectories(p);
268267
}
269268

270-
void pathCreateArchive(const String &path, const String &options)
269+
void pathCreateArchiveZip(const String &path)
271270
{
272271
ScopeLock lock(fsMutex());
273272
if (any(pathType(path) & (PathTypeFlags::File | PathTypeFlags::Directory | PathTypeFlags::Archive)))
274273
{
275274
CAGE_LOG_THROW(Stringizer() + "path: " + path);
276275
CAGE_THROW_ERROR(Exception, "cannot create archive, the path already exists");
277276
}
278-
archiveCreateZip(path, options);
277+
archiveCreateZip(path);
278+
}
279+
280+
void pathCreateArchiveCarch(const String &path)
281+
{
282+
ScopeLock lock(fsMutex());
283+
if (any(pathType(path) & (PathTypeFlags::File | PathTypeFlags::Directory | PathTypeFlags::Archive)))
284+
{
285+
CAGE_LOG_THROW(Stringizer() + "path: " + path);
286+
CAGE_THROW_ERROR(Exception, "cannot create archive, the path already exists");
287+
}
288+
archiveCreateCarch(path);
279289
}
280290

281291
namespace

0 commit comments

Comments
 (0)