Skip to content

Commit

Permalink
Fixed pck file path generation on Windows
Browse files Browse the repository at this point in the history
now when using wine on Linux the Windows version can make pck files
from scratch that Godot can load
  • Loading branch information
hhyyrylainen committed May 11, 2020
1 parent e870f8e commit b98ad13
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.10)
project(GodotPckTool)

set(GODOT_PCK_TOOL_VERSION_MAJOR 1)
set(GODOT_PCK_TOOL_VERSION_MINOR 1)
set(GODOT_PCK_TOOL_VERSION_MINOR 2)

set(GODOT_PCK_TOOL_VERSION_STR "${GODOT_PCK_TOOL_VERSION_MAJOR}.${GODOT_PCK_TOOL_VERSION_MINOR}")

Expand Down
11 changes: 10 additions & 1 deletion src/pck/PckFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ bool PckFile::AddFilesFromFilesystem(const std::string& path, const std::string&
return true;
}

void PckFile::AddSingleFile(const std::string& filesystemPath, const std::string& pckPath)
void PckFile::AddSingleFile(const std::string& filesystemPath, std::string pckPath)
{
if(pckPath.empty())
throw std::runtime_error("path inside pck is empty to add file to");

std::cout << "Adding " << filesystemPath << " as " << pckPath << "\n";

ContainedFile file;
Expand Down Expand Up @@ -253,6 +256,12 @@ std::string PckFile::PreparePckPath(std::string path, const std::string& stripPr
path = path.substr(stripPrefix.size());
}

// Fix Windows paths to make this work on Windows
for(size_t i = 0; i < path.size(); ++i) {
if(path[i] == '\\')
path[i] = '/';
}

while(path.size() > 0 && path.front() == '/') {
path.erase(path.begin());
}
Expand Down
3 changes: 2 additions & 1 deletion src/pck/PckFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ class PckFile {
//! \brief Adds recursively files from path to this pck
bool AddFilesFromFilesystem(const std::string& path, const std::string& stripPrefix);

void AddSingleFile(const std::string& filesystemPath, const std::string& pckPath);
void AddSingleFile(const std::string& filesystemPath, std::string pckPath);

//! \note Automatically converts \'s in the path to /'s
std::string PreparePckPath(std::string path, const std::string& stripPrefix);

void ChangePath(const std::string& path);
Expand Down

0 comments on commit b98ad13

Please sign in to comment.