Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Linux Compatibility #19

Merged
merged 7 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion www/include/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function clone($destinationDirectory, $branch = 'master', $sparseFolders
}
} else {
$out = $this->execute("git clone {$escRepo} {$escDestDir}");
print_r($out);
}
}

Expand Down
11 changes: 8 additions & 3 deletions www/update.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function copyFolder($sourceFolder, $destinationFolder)
logDebug("Copy '$sourceFolder' to '$destinationFolder' succeeded.\n");
} else {
logDebug("Failed to copy '$sourceFolder' to '$destinationFolder'.\n");
logDebug("Status = ".$returnStatus." Output:".$output."\n");
}
}

Expand All @@ -86,7 +87,8 @@ function deleteFolder($folder)
if ($returnStatus === 0) {
logDebug("Deleted folder '$folder' succeeded.\n");
} else {
logDebug("Failed to delete folder '$folder'.\n");
logDebug("Failed to delete folder '$folder'. \n");
logDebug("Status = ".$returnStatus." Output:".$output."\n");
}
}

Expand Down Expand Up @@ -122,6 +124,8 @@ function getFiles(string $directory): array
return $allFiles;
}

// Note: Built-in PHP file functions under Windows will accept forward slashes as directory separators, such as is_dir(), is_file(), etc.
// Shell commands such as exec() are an exception. Use DIRECTORY_SEPARATOR constant to prepare path names.
function path(...$parts) {
// Remove leading and trailing slashes from each part before joining them.
$parts = array_map(function($part) {
Expand Down Expand Up @@ -204,12 +208,13 @@ function locfileToPhp($locContent)
copyFolder($repoDir . "/projectiles", path($dataFolder, 'projectiles'));
copyFolder($repoDir . "/units", path($dataFolder, 'units'));
copyFolder($repoDir . "/loc", path($locFolder, 'loc', 'loc'));

unzipFiles("data/gamedata/projectiles.scd.3599", path($dataFolder, 'projectiles.3599'));
unzipFiles("data/gamedata/units.scd.3599", path($dataFolder, 'units.3599'));
unzipFiles("data/loc/loc_US.scd.3599", path($locFolder, 'loc_US.3599'));
unzipFiles("data/loc/loc.nx2", path($locFolder, 'loc.nx2'));

$folders = [ 'projectiles.3599', 'units.3599', 'projectiles', 'units', 'loc\\loc_US.3599', 'loc\\loc.nx2'];
$folders = [ 'projectiles.3599', 'units.3599', 'projectiles', 'units', 'loc/loc_US.3599', 'loc/loc.nx2'];
$valid_types = [ 'unit.bp', 'proj.bp', 'db.lua' ];

$blueprints = array();
Expand All @@ -220,7 +225,7 @@ function locfileToPhp($locContent)
// The .3599 folders must be read first, otherwise old values will appear in the results.

foreach ($folders as $thisFolder) {
$thisPath = $dataFolder."\\".$thisFolder;
$thisPath = $dataFolder."/".$thisFolder;

$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($thisPath));
foreach ($iterator as $file) {
Expand Down
Loading