{"record":{"id":"11679ee3b51a0ae3","repo":"DrKLO/Telegram","slug":"can-t-open-scan-definition-file-s","errorCode":null,"errorMessage":"Can't open scan definition file %s\n","messagePattern":"Can't open scan definition file (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/rdswitch.c","lineNumber":196,"sourceCode":" * in the current scan.  The first component has index 0.\n * Sequential JPEG is used if the progressive-JPEG parameters are omitted.\n * The file is free format text: any whitespace may appear between numbers\n * and the ':' and ';' punctuation marks.  Also, other punctuation (such\n * as commas or dashes) can be placed between numbers if desired.\n * Comments preceded by '#' may be included in the file.\n * Note: we do very little validity checking here;\n * jcmaster.c will validate the script parameters.\n */\n{\n  FILE *fp;\n  int scanno, ncomps, termchar;\n  long val;\n  jpeg_scan_info *scanptr;\n#define MAX_SCANS  100          /* quite arbitrary limit */\n  jpeg_scan_info scans[MAX_SCANS];\n\n  if ((fp = fopen(filename, \"r\")) == NULL) {\n    fprintf(stderr, \"Can't open scan definition file %s\\n\", filename);\n    return FALSE;\n  }\n  scanptr = scans;\n  scanno = 0;\n\n  while (read_scan_integer(fp, &val, &termchar)) {\n    if (scanno >= MAX_SCANS) {\n      fprintf(stderr, \"Too many scans defined in file %s\\n\", filename);\n      fclose(fp);\n      return FALSE;\n    }\n    scanptr->component_index[0] = (int) val;\n    ncomps = 1;\n    while (termchar == ' ') {\n      if (ncomps >= MAX_COMPS_IN_SCAN) {\n        fprintf(stderr, \"Too many components in one scan in file %s\\n\",\n                filename);\n        fclose(fp);","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/rdswitch.c#L178-L214","documentation":"The set_scan_partitions function (which reads scan definition scripts for progressive JPEG encoding) attempts to fopen the file specified by the -scans argument. If fopen returns NULL, the scan definition file does not exist or is inaccessible. The function returns FALSE. Scan files define the progression order and component grouping for progressive JPEG output.","triggerScenarios":"Calling cjpeg with -scans <file> where <file> does not exist or is unreadable. The fopen(filename, 'r') at the entry of the scan-reading function returns NULL.","commonSituations":"Typo in the scan file path; file not deployed to the expected location; wrong working directory; permissions issue; the scan script was never created.","solutions":["Verify the scan definition file exists and is readable: test -f <file> and test -r <file>.","Use an absolute path for the scan file to avoid working-directory ambiguity.","Create the scan definition file if it does not exist, following the expected format (component indices, Ss, Se, Ah, Al values separated by spaces and colons)."],"exampleFix":"# before\ncjpeg -scans missing.scans image.bmp > out.jpg\n# after\ncjpeg -scans /path/to/progressive.scans image.bmp > out.jpg","handlingStrategy":"validation","validationCode":"// In C: check file accessibility before calling the scan reader\n#include <unistd.h>\nif (access(filename, R_OK) != 0) {\n  fprintf(stderr, \"Scan file %s is not readable\\n\", filename);\n  return FALSE;\n}\n// Then call the actual scan definition reader","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use access(filename, R_OK) to verify readability before passing scan files.","Use absolute paths for scan definition files.","Keep scan files in version control to prevent path or content drift."],"tags":["filesystem","file-not-found","scan-definition","mozjpeg"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}