medfall

A super great game engine
Log | Files | Refs

commit 8c6f7871e5421c262851a478d577e6af2cbcb0f6
parent 272fbbaf21691664a891fe18166264dc9d0c4aae
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue Jul  4 22:14:24 +0300

chmod +x platform specific files on Unix platforms. Game ships on Linux now!

Diffstat:
launcher/main.cc | 18++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/launcher/main.cc b/launcher/main.cc @@ -18,6 +18,7 @@ #include "strlcpy.h" #include "strtonum.h" #include "patterns.h" +#include "platform.h" #include "platform_exec.h" #include "platform_io.h" #include "platform_network.h" @@ -132,6 +133,7 @@ static bool parse_sha256( SHA256 * sha256, const array< const char > hex ) { struct ManifestEntry { SHA256 checksum; u64 file_size; + bool platform_specific; }; struct Version { @@ -169,9 +171,8 @@ static bool parse_manifest( std::map< std::string, ManifestEntry > & manifest, c const str< 16 > file_size( "{}", matches[ 2 ] ); const str< 32 > file_platform( "{}", matches[ 3 ] ); u64 size = u64( strtonum( file_size.c_str(), 1, S64_MAX, NULL ) ); - ManifestEntry entry; - entry.file_size = size; + ManifestEntry entry; bool ok_sha = parse_sha256( &entry.checksum, matches[ 1 ] ); if( matches[ 0 ].n > file_name.len() || matches[ 2 ].n > file_size.len() || matches[ 3 ].n > file_platform.len() || size == 0 || !ok_sha ) { @@ -183,6 +184,9 @@ static bool parse_manifest( std::map< std::string, ManifestEntry > & manifest, c continue; } + entry.file_size = size; + entry.platform_specific = file_platform != ""; + manifest[ file_name.c_str() ] = entry; } @@ -441,11 +445,21 @@ static WORK_QUEUE_CALLBACK( download_file ) { std::string local_path = "update/" + file->file_name; recursive_mkdir( NULL, local_path.c_str() ); + FILE * f = fopen( local_path.c_str(), "wb" ); if( f == NULL ) { FATAL( "couldn't open {} for writing", local_path.c_str() ); } fwrite( body.c_str(), 1, body.size(), f ); + +#if PLATFORM_UNIX + if( entry.platform_specific ) { + // mark executable + int fd = fileno( f ); + fchmod( fd, 0755 ); + } +#endif + fclose( f ); file->done = true;