1 #! /usr/bin/env python3
2 """Dummy VFS for Midnight Commander. Just for a test."""
5 __author__ = "Oleg Broytman <phd@phdru.name>"
6 __copyright__ = "Copyright (C) 2004-2023 PhiloSoft Design"
14 sys.stderr.write(msg + '\n')
24 It is not a program - it is a dummy VFS for Midnight Commander.
25 Put it in $HOME/.mc/extfs.d or /usr/lib/mc/extfs.""")
29 """List the entire VFS"""
30 # Ignore the VFS name (sys.argv[2])
31 # Emit a dummy listing
32 print("-r--r--r-- 1 user group 0 Jun 13 02:20 file0")
33 print("-r--r--r-- 1 user group 1 Jun 13 02:21 file1")
34 print("dr--r--r-- 1 user group 2 Jun 13 02:22 subdir")
35 print("-r--r--r-- 1 user group 3 Jun 13 02:23 subdir/file3")
36 print("-r--r--r-- 1 user group 4 Jun 13 02:23 subdir/file4")
39 def mcdummy_copyout():
40 """Extract a file from the VFS"""
41 # Ignore the VFS name (sys.argv[2])
42 dummy_filename = sys.argv[3]
43 real_filename = sys.argv[4]
45 real_file = open(real_filename, 'a')
46 real_file.write("Copy from %s\n" % dummy_filename)
47 real_file.write("Copy to %s\n" % real_filename)
52 """Put a file to the VFS"""
53 # Ignore the VFS name (sys.argv[2])
54 dummy_filename = sys.argv[3]
55 real_filename = sys.argv[4]
57 real_file = open(real_filename + "-dummy.tmp", 'a')
58 real_file.write("Copy from %s\n" % real_filename)
59 real_file.write("Copy to %s\n" % dummy_filename)
64 """Remove a file from the VFS"""
65 # Ignore the VFS name (sys.argv[2])
66 dummy_filename = sys.argv[3]
68 real_file = open(".dummy.tmp", 'a')
69 real_file.write("Remove %s\n" % dummy_filename)
74 """Create a directory in the VFS"""
75 # Ignore the VFS name (sys.argv[2])
76 dummy_dirname = sys.argv[3]
78 real_file = open(".dummy.tmp", 'a')
79 real_file.write("Create %s\n" % dummy_dirname)
84 """Remove a directory from the VFS"""
85 # Ignore the VFS name (sys.argv[2])
86 dummy_dirname = sys.argv[3]
88 real_file = open(".dummy.tmp", 'a')
89 real_file.write("Remove %s\n" % dummy_dirname)
95 procname = "mcdummy_" + command
98 error("Unknown command %s" % command)