Useless temporary files created by viewer - fixed



Hello!

Somebody noted on the list that MC creates an useless temporary file when
the viewer is active.

Unfortunately, the complete fix is quite hard to do. It would involve
creating the temporary file on demand (and process possible errors) when
exec_extension() wants to write it.

However, I have changed exec_extension() so that the temporary file is
unlinked immediately after it's closed if nothing significant has been
written into it. This means that when the viewer is active, the temporary
file doesn't exist anymore.

Also the block surrounded by "#ifdef OLD_CODE" ... "#endif" has been
removed. It was left just for information, but somebody ("cvs annotate" is
your friend) internationalized the strings in that block, thus adding work
to all translators.

Please remove the unused code! This makes code easier to read and saves
translators' time.

-- 
Regards,
Pavel Roskin

------------------------------------------
--- ext.c
+++ ext.c
@@ -247,7 +247,15 @@ exec_extension (const char *filename, co
     } /* for */
     fputc ('\n', cmd_file);
     fclose (cmd_file);
-    chmod (file_name, S_IRWXU);
+
+    if ((run_view && !written_nonspace) || is_cd) {
+	unlink (file_name);
+	g_free (file_name);
+	file_name = NULL;
+    } else {
+	chmod (file_name, S_IRWXU);
+    }
+
     if (run_view){
     	altered_hex_mode = 0;
     	altered_nroff_flag = 0;
@@ -302,22 +310,17 @@ exec_extension (const char *filename, co
 	    }
 	}
 #endif /* !HAVE_X */
-
-#ifdef OLD_CODE
-	if (vfs_current_is_local ())
-	    shell_execute (file_name, EXECUTE_INTERNAL);
-	else
-	    message (1, _(" Warning "), _(" Can't execute commands on a Virtual File System directory "));
-#endif
     }
 #ifndef PORT_DOES_BACKGROUND_EXEC
-    unlink (file_name);
+    if (file_name) {
+	unlink (file_name);
+	g_free (file_name);
+    }
 #endif
     if (localcopy) {
         mc_stat (localcopy, &mystat);
         mc_ungetlocalcopy (filename, localcopy, localmtime != mystat.st_mtime);
     }
-    g_free (file_name);
 }

 #ifdef FILE_L
------------------------------------------





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]