5 # turn a symlink to a directory into a real directory
13 error = 'mkreal error'
18 st = os.stat(name) # Get the mode
19 mode = S_IMODE(st[ST_MODE])
20 linkto = os.readlink(name) # Make sure again it's a symlink
21 f_in = open(name, 'r') # This ensures it's a file
23 f_out = open(name, 'w')
25 buf = f_in.read(BUFSIZE)
28 del f_out # Flush data to disk before changing mode
32 st = os.stat(name) # Get the mode
33 mode = S_IMODE(st[ST_MODE])
34 linkto = os.readlink(name)
35 files = os.listdir(name)
39 linkto = join(os.pardir, linkto)
41 for filename in files:
42 if filename not in (os.curdir, os.pardir):
43 os.symlink(join(linkto, filename), join(name, filename))
46 sys.stdout = sys.stderr
47 progname = os.path.basename(sys.argv[0])
48 if progname == '-c': progname = 'mkreal'
51 print 'usage:', progname, 'path ...'
55 if not os.path.islink(name):
56 print progname+':', name+':', 'not a symlink'
59 if os.path.isdir(name):
65 if __name__ == '__main__':