X-Git-Url: https://git.phdru.name/?p=extfs.d.git;a=blobdiff_plain;f=dummy;h=034cf0fe79b1cb5d1aaffcc2a358e70afced2051;hp=312a47ddca15c2f64cafbfc876f8118cff952ecd;hb=c1fd444890ddd1bb30699e88037ff9815e9a10ff;hpb=0122acf0a01fb368a705af3f51ba780bd7551090 diff --git a/dummy b/dummy index 312a47d..034cf0f 100755 --- a/dummy +++ b/dummy @@ -3,17 +3,15 @@ """ Dummy VFS for Midnight Commander. Just for a test. -Author: Oleg BroytMann . -Copyright (C) 2004 PhiloSoft Design. -License: GPL. - """ -__version__ = "0.0.1" -__revision__ = "$Id: dummy,v 1.1 2004/06/12 22:14:57 phd Exp $" -__date__ = "$Date: 2004/06/12 22:14:57 $"[7:-2] -__author__ = "Oleg Broytmann " -__copyright__ = "Copyright (C) 2004 PhiloSoft Design" +__version__ = "1.0.1" +__revision__ = "$Id$" +__date__ = "$Date$"[7:-2] +__author__ = "Oleg Broytman " +__copyright__ = "Copyright (C) 2004-2009 PhiloSoft Design" +__license__ = "GPL" + import sys @@ -21,12 +19,86 @@ def log_error(msg): sys.stderr.write(msg + '\n') def error(msg): - sys.stderr.write(msg + '\n') + log_error(msg + '\n') sys.exit(1) if len(sys.argv) < 2: - error("Not enough arguments") + error("""\ +It is not a program - it is a dummy VFS for Midnight Commander. +Put it in /usr/lib/mc/extfs.""") + + +def mcdummy_list(): + """List the entire VFS""" + # Ignore the VFS name (sys.argv[2]) + # Emit a dummy listing + print "-r--r--r-- 1 user group 0 Jun 13 02:20 file0" + print "-r--r--r-- 1 user group 1 Jun 13 02:21 file1" + print "dr--r--r-- 1 user group 2 Jun 13 02:22 subdir" + print "-r--r--r-- 1 user group 3 Jun 13 02:23 subdir/file3" + print "-r--r--r-- 1 user group 4 Jun 13 02:23 subdir/file4" + + +def mcdummy_copyout(): + """Extract a file from the VFS""" + # Ignore the VFS name (sys.argv[2]) + dummy_filename = sys.argv[3] + real_filename = sys.argv[4] + + real_file = open(real_filename, 'a') + real_file.write("Copy from %s\n" % dummy_filename) + real_file.write("Copy to %s\n" % real_filename) + real_file.close() + + +def mcdummy_copyin(): + """Put a file to the VFS""" + # Ignore the VFS name (sys.argv[2]) + dummy_filename = sys.argv[3] + real_filename = sys.argv[4] + + real_file = open(real_filename + "-dummy.tmp", 'a') + real_file.write("Copy from %s\n" % real_filename) + real_file.write("Copy to %s\n" % dummy_filename) + real_file.close() + + +def mcdummy_rm(): + """Remove a file from the VFS""" + # Ignore the VFS name (sys.argv[2]) + dummy_filename = sys.argv[3] + + real_file = open(".dummy.tmp", 'a') + real_file.write("Remove %s\n" % dummy_filename) + real_file.close() + + +def mcdummy_mkdir(): + """Create a directory in the VFS""" + # Ignore the VFS name (sys.argv[2]) + dummy_dirname = sys.argv[3] + + real_file = open(".dummy.tmp", 'a') + real_file.write("Create %s\n" % dummy_dirname) + real_file.close() + + +def mcdummy_rmdir(): + """Remove a directory from the VFS""" + # Ignore the VFS name (sys.argv[2]) + dummy_dirname = sys.argv[3] + + real_file = open(".dummy.tmp", 'a') + real_file.write("Remove %s\n" % dummy_dirname) + real_file.close() + + +g = globals() +command = sys.argv[1] +procname = "mcdummy_" + command +if not g.has_key(procname): + error("Unknown command %s" % command) -cmd = sys.argv[1] +g[procname]()