{"record":{"id":"ad9455ed2bf959a3","repo":"DrKLO/Telegram","slug":"s-can-t-open-s-n-ad9455","errorCode":null,"errorMessage":"%s: can't open %s\\n","messagePattern":"(.+?): can't open (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/wrjpgcom.c","lineNumber":495,"sourceCode":"      }\n      comment_length = (unsigned int)strlen(comment_arg);\n    } else\n      usage();\n  }\n\n  /* Cannot use both -comment and -cfile. */\n  if (comment_arg != NULL && comment_file != NULL)\n    usage();\n  /* If there is neither -comment nor -cfile, we will read the comment text\n   * from stdin; in this case there MUST be an input JPEG file name.\n   */\n  if (comment_arg == NULL && comment_file == NULL && argn >= argc)\n    usage();\n\n  /* Open the input file. */\n  if (argn < argc) {\n    if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, argv[argn]);\n      exit(EXIT_FAILURE);\n    }\n  } else {\n    /* default input file is stdin */\n#ifdef USE_SETMODE              /* need to hack file mode? */\n    setmode(fileno(stdin), O_BINARY);\n#endif\n#ifdef USE_FDOPEN               /* need to re-open in binary mode? */\n    if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open stdin\\n\", progname);\n      exit(EXIT_FAILURE);\n    }\n#else\n    infile = stdin;\n#endif\n  }\n\n  /* Open the output file. */","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/wrjpgcom.c#L477-L513","documentation":"After switch parsing, wrjpgcom opens the input JPEG. If a positional file name was supplied (argn < argc) but fopen(argv[argn], READ_BINARY) fails, it prints `%s: can't open %s` (progname, path) and exits EXIT_FAILURE. This is an input-image open failure, distinct from the -cfile open failure at line 437.","triggerScenarios":"Running `wrjpgcom [opts] <input.jpg>` where <input.jpg> is missing, unreadable, not a regular file, or not a JPEG at all (open still succeeds for non-JPEG; this specific message is only the open failure).","commonSituations":"Wrong input path/extension typo, file deleted between parse and open, permission denied, or a path with spaces passed unquoted so argv splits incorrectly.","solutions":["Confirm the input JPEG path exists and is readable (`test -r`).","Quote paths containing spaces so they reach argv as one token.","Use an absolute path to avoid cwd mismatch.","Ensure the file is a valid readable JPEG, not a truncated/zero-byte file."],"exampleFix":"// before\nwrjpgcom -cfile c.txt my photo.jpg\n// after\nwrjpgcom -cfile c.txt \"my photo.jpg\"","handlingStrategy":"validation","validationCode":"#include <unistd.h>\n/* verify input JPEG is readable before launching wrjpgcom */\nif (access(input_jpg, R_OK) != 0) { /* report and abort */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote input paths containing spaces.","Use absolute input paths.","Confirm the file is a complete, readable JPEG."],"tags":["cli","jpeg","mozjpeg","wrjpgcom","file-io","input-validation"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}