MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / isArchivable

Method isArchivable

src/OpenColorIO/Config.cpp:6008–6081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6006}
6007
6008bool Config::isArchivable() const
6009{
6010 ConstContextRcPtr context = getCurrentContext();
6011
6012 // Current archive implementation needs a working directory to look for LUT files and
6013 // working directory must be an absolute path.
6014 const char * workingDirectory = getWorkingDir();
6015 if ((workingDirectory && !workingDirectory[0]) || !pystring::os::path::isabs(workingDirectory))
6016 {
6017 return false;
6018 }
6019
6020 // Utility lambda to check the following criteria.
6021 auto validatePathForArchiving = [](const std::string & path)
6022 {
6023 // Using the normalized path.
6024 const std::string normPath = pystring::os::path::normpath(path);
6025 if (
6026 // 1) Path may not be absolute.
6027 pystring::os::path::isabs(normPath) ||
6028 // 2) Path may not start with double dot ".." (going above working directory).
6029 pystring::startswith(normPath, "..") ||
6030 // 3) A context variable may not be located at the start of the path.
6031 (ContainsContextVariables(path) &&
6032 (StringUtils::Find(path, "$") == 0 ||
6033 StringUtils::Find(path, "%") == 0)))
6034 {
6035 return false;
6036 }
6037
6038 return true;
6039 };
6040
6041 ///////////////////////////////
6042 // Search path verification. //
6043 ///////////////////////////////
6044 // Check that search paths are not absolute nor have context variables outside of config
6045 // working directory.
6046 int numSearchPaths = getNumSearchPaths();
6047 for (int i = 0; i < numSearchPaths; i++)
6048 {
6049 std::string currentPath = getSearchPath(i);
6050 if (!validatePathForArchiving(currentPath))
6051 {
6052 // Exit and return false.
6053 return false;
6054 }
6055 }
6056
6057 /////////////////////////////////
6058 // FileTransform verification. //
6059 /////////////////////////////////
6060 ConstTransformVec allTransforms;
6061 getImpl()->getAllInternalTransforms(allTransforms);
6062
6063 std::set<std::string> files;
6064 for(const auto & transform : allTransforms)
6065 {

Callers 5

mainFunction · 0.80
archiveConfigFunction · 0.80
test_is_archivableMethod · 0.80
OCIO_ADD_TESTFunction · 0.80

Calls 5

ContainsContextVariablesFunction · 0.85
FindFunction · 0.85
GetFileReferencesFunction · 0.85
getImplFunction · 0.50

Tested by 3

test_is_archivableMethod · 0.64
OCIO_ADD_TESTFunction · 0.64