208,13 → 208,17 |
char* q = (char*)PILOCKHANDLE(h, false); |
|
len = *((uint32_t*)q); |
if (len == 6) { |
if (len != 6) { |
res = MSG_INVALID_FILE_SIGNATURE_ID; |
} else { |
val = _ffx_read_str(&q); |
if (strcmp(val, "FFX1.0") == 0) format_version = 10; |
else if (strcmp(val, "FFX1.1") == 0) format_version = 11; |
else if (strcmp(val, "FFX1.2") == 0) format_version = 12; |
free(val); |
if (format_version > 0) { |
if (format_version < 0) { |
res = MSG_INVALID_FILE_SIGNATURE_ID; |
} else { |
simplewarning_id(MSG_FILTERS_UNLIMITED_WARNING_ID); |
|
val = _ffx_read_str(&q); |
328,7 → 332,7 |
FSClose(refnum); |
} |
|
if (res) gdata->obfusc = false; |
if (res == 0) gdata->obfusc = false; |
return res; |
} |
|
352,7 → 356,7 |
for( count /= 4 ; count >= PARM_SIZE/4 ; --count, ++q ) |
{ |
res = readPARM(&gdata->parm, (Ptr)q); |
if (res) break; |
if (res == 0) break; |
} |
|
PIDISPOSEHANDLE(h); |
363,7 → 367,7 |
}else |
res = MSG_CANNOT_OPEN_FILE_ID; |
|
if (res) gdata->obfusc = false; |
if (res == 0) gdata->obfusc = false; |
return res; |
} |
|
697,8 → 701,6 |
FFLoadingResult res = MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
FILEREF refnum; |
|
if (!fileHasExtension(sfr, TEXT(".txt"))) return MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
|
if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) { |
if ((h = readfileintohandle(refnum))) { |
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h); |
855,8 → 857,6 |
|
// TODO: Decode UTF-8 to ANSI (or "?" for unknown characters) |
|
if (!fileHasExtension(sfr, TEXT(".guf"))) return MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
|
if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) { |
if ((h = readfileintohandle(refnum))) { |
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h); |
945,15 → 945,10 |
|
if(FSpOpenDF(&sfr->sfFile,fsRdPerm,&r) == noErr){ |
if( (h = readfileintohandle(r)) ){ |
if( 0 != (res = readparams_afs_pff(h, fileHasExtension(sfr, TEXT(".pff")))) ) { |
// If .afs and .pff files are not recognized, then it is a hard error. |
// If a .txt file has no "%RGB1.0" signature, then it is OK and |
// we will return MSG_LOADFILE_UNKNOWN_FORMAT_ID to inform the caller that they shall continue trying formats. |
if (!fileHasExtension(sfr, TEXT(".afs")) && !fileHasExtension(sfr, TEXT(".pff"))) { |
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
} |
} |
|
// Note in re fileHasExtension(): Mac does not have file extensions like Windows, |
// so, the detection if the channel order is BGRA (Premiere *.pff) or RGBA (Photoshop *.afs) |
// is not possible, except if the file has an extension (e.g. when it was copied from a Windows system) |
res = readparams_afs_pff(h, fileHasExtension(sfr, TEXT(".pff"))); |
PIDISPOSEHANDLE(h); |
} |
FSClose(r); |
974,9 → 969,6 |
size_t est; |
int foundFilters = 0; |
|
// TODO: sollte von außerhalb gesteuert werden [auch bei anderen] |
if (!fileHasExtension(sfr, TEXT(".ffl"))) return MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
|
if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) { |
if ((h = readfileintohandle(refnum))) { |
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h); |
984,8 → 976,12 |
|
char* q2, * tmp_cur_filter_str[29], *token; |
int lineNumber = 0; |
int countFilters = 0; |
|
if (strstr(q, "FFL1.0") != q) { |
res = MSG_INVALID_FILE_SIGNATURE_ID; |
} |
else { |
|
// This is required to make strtok work, because q is not zero-terminated... |
q2 = (char*)malloc(count + 1/*NUL byte*/); |
if (q2 == NULL) { |
1003,13 → 999,19 |
if (token2[i] == '\r') token2[i] = '\0'; |
} |
if (lineNumber == 0) { |
// We already checked it above (in order to avoid an unnecessary memory copy) |
/* |
if (strcmp(token2, "FFL1.0") != 0) { |
res = MSG_INVALID_FILE_SIGNATURE_ID; |
break; |
} |
*/ |
} |
else if (lineNumber == 1) { |
else if (lineNumber > 1) { |
// We don't check that. We just stop at every 28th line of each filter |
/* |
countFilters = atoi(token2); |
*/ |
} |
else |
{ |
1147,6 → 1149,7 |
} |
|
free(q2); |
} |
|
PIUNLOCKHANDLE(h); |
PIDISPOSEHANDLE(h); |