@@ -202,15 +202,28 @@ void addSupportedFiles(void * archiver, const char * path, const char * configWo
202202}
203203// ////////////////////////////////////////////////////////////////////////////////////
204204
205- void archiveConfig (std::ostream & ostream, const Config & config, const char * configWorkingDirectory)
205+ ArchiveFlags EnvironmentOverride (ArchiveFlags oFlags) // TODO: test override
206+ {
207+ const std::string envFlag = GetEnvVariable (OCIO_ARCHIVE_FLAGS_ENVVAR);
208+ if (!envFlag.empty ())
209+ {
210+ // Use 0 to allow base to be determined by the format.
211+ oFlags = static_cast <ArchiveFlags>(std::stoul (envFlag, nullptr , 0 ));
212+ }
213+ return oFlags;
214+ }
215+
216+ void archiveConfig (std::ostream & ostream, const Config & config, const char * configWorkingDirectory, ArchiveFlags flags)
206217{
207218 void * archiver = nullptr ;
208219 void *write_mem_stream = NULL ;
209220 const uint8_t *buffer_ptr = NULL ;
210221 int32_t buffer_size = 0 ;
211222 mz_zip_file file_info;
212223
213- if (!config.isArchivable ())
224+ flags = EnvironmentOverride (flags);
225+
226+ if (!config.isArchivable ()) // TODO: pass in flags?
214227 {
215228 std::ostringstream os;
216229 os << " Config is not archivable." ;
@@ -238,8 +251,10 @@ void archiveConfig(std::ostream & ostream, const Config & config, const char * c
238251 ArchiveOptions options;
239252 // Make sure that the compression method is set to DEFLATE.
240253 options.compress_method = ArchiveCompressionMethods::DEFLATE;
241- // Make sure that the compression level is set to BEST.
242- options.compress_level = ArchiveCompressionLevels::BEST;
254+ // Default compression level is set to BEST.
255+ options.compress_level = flags & ARCHIVE_FLAGS_COMPRESSION_MASK
256+ ? ArchiveCompressionLevels (flags & ARCHIVE_FLAGS_COMPRESSION_MASK)
257+ : ArchiveCompressionLevels::BEST;
243258
244259 // Create the writer handle.
245260#if MZ_VERSION_BUILD >= 040000
@@ -305,7 +320,10 @@ void archiveConfig(std::ostream & ostream, const Config & config, const char * c
305320 // /////////////////////
306321 // Add all supported files to in-memory zip from any directories under working directory.
307322 // (recursive)
308- addSupportedFiles (archiver, configWorkingDirectory, configWorkingDirectory);
323+ if (HasFlag (flags, ARCHIVE_FLAGS_MINIMAL))
324+ addSupportedFiles (archiver, configWorkingDirectory, configWorkingDirectory);
325+ else
326+ addSupportedFiles (archiver, configWorkingDirectory, configWorkingDirectory);
309327
310328 // Close in-memory zip.
311329 mz_zip_writer_close (archiver);
0 commit comments