Kaynağa Gözat

Try fallbak for missing apps, use popen wrapper

master
Arun Prakash Jana 8 yıl önce
ebeveyn
işleme
205dd6db05
Veri tabanında bu imza için bilinen anahtar bulunamadı GPG Anahtar Kimliği: A75979F35C080412
1 değiştirilmiş dosya ile 6 ekleme ve 8 silme
  1. +6
    -8
      nnn.c

+ 6
- 8
nnn.c Dosyayı Görüntüle

@@ -1141,7 +1141,6 @@ nochange:
static char cmd[MAX_CMD_LEN]; static char cmd[MAX_CMD_LEN];
static char *runvi = "vi"; static char *runvi = "vi";
static int status; static int status;
static FILE *fp;


/* If default mime opener is set, use it */ /* If default mime opener is set, use it */
if (opener) { if (opener) {
@@ -1155,20 +1154,19 @@ nochange:
/* Try custom applications */ /* Try custom applications */
bin = openwith(newpath); bin = openwith(newpath);


/* If custom app doesn't exist try fallback */
snprintf(cmd, MAX_CMD_LEN, "which \"%s\"", bin);
if (get_output(cmd, MAX_CMD_LEN) == NULL)
bin = NULL;

if (bin == NULL) { if (bin == NULL) {
/* If a custom handler application is /* If a custom handler application is
not set, open plain text files with not set, open plain text files with
vi, then try fallback_opener */ vi, then try fallback_opener */
snprintf(cmd, MAX_CMD_LEN, snprintf(cmd, MAX_CMD_LEN,
"file \"%s\"", newpath); "file \"%s\"", newpath);
fp = popen(cmd, "r"); if (get_output(cmd, MAX_CMD_LEN) == NULL)
if (fp == NULL)
goto nochange;
if (fgets(cmd, MAX_CMD_LEN, fp) == NULL) {
pclose(fp);
goto nochange; goto nochange;
}
pclose(fp);


if (strstr(cmd, "ASCII text") != NULL) if (strstr(cmd, "ASCII text") != NULL)
bin = runvi; bin = runvi;


||||||
x
 
000:0
Yükleniyor…
İptal
Kaydet