copying directories (amazing next)

ZXNet echo conference «zxnet.pc»

From Kirill Frolov To All 5 April 2003

================================================================================ * Forwarded by Kirill Frolov (500:812/1.507) * Area : ru.dos (ru.dos) * From : Nick Mikhailenko, 2:5020/194.118 (03 Apr 03 06:13) * To : All * Subj : copying directories (amazing next) ================================================================================ RealName Mikhailenko Nikolai Nikolaevich Hello All! It would seem that there can be no ambiguities when copying files, however... Initial file configuration. The file in parentheses on the left is contained in this subdirectory ▌▐ └──Y └──Y └──Y (yfile) └──Z (zfile) Copy result: YY -> \n different file managers NC.EXE v 5.0 1995 VC.COM v 4.05 2000 FAR.EXE v 1.70b4 2002 F5: YY -> \n Look, subdirectory Z was copied twice ▌▐ └──Y ├──Z (zfile) └──Y (yfile) ├──Y (yfile) │ └──Z (zfile) └──Z (zfile) Win 98, xcopy YY /e The trick here is that it is not the YY directory that is copied, but its _contents_ It turns out that this is what ▌▐ └──Y (yfile) ├──Y │ └──Y (yfile) │ └──Z (zfile) └──Z (zfile) Win 98, Explorer VC.COM v 4.99.08a 2000 CC.EXE freeware 2003 ▌▐ └──Y └──Y (yfile) ├──Y (yfile) │ └──Z (zfile) └──Z (zfile) Guess three times which copy option is correctSee how directories are copied under Linux Directory tree copying algorithm ══════════════════════════════════════ The following circumstances must be taken into account: 1. Going down to a new directory, first copy all its files and only then move on to the subdirectories 2. Subdirectories of the form Y(Y)... are copied last (all subdirectories in the chain have the same name) 3. If, when climbing up the directory tree, we end up in a directory of this type, then the copying process is considered complete ══════════════════════════════════════ I thought the problem had been solved, but Vitya Khimenko doubted that The corrected copying algorithm covers all cases. I told him emphatically no. But soon he himself came up with a counterexample. Create a chain XYXYX and copy XYX -> \n The SI commander screwed up and copied the Z subdirectory twice But Windows Explorer 98 and Wolf 08a worked correctly. I can't imagine how they achieve this. For myself, I decided that it was enough to complicate the copying algorithm. This has no practical significance. The examples are tortured. And the user needs to know that he should not copy a directory branch up with overlapping yourself. And if you really want to, then do it in two stages with an intermediate goal. First somewhere to the side, and then wherever necessary. By the way, in a similar way, in two steps you can copy a directory _to yourself_.In this case, no reproduction of directories with the same name will occur. ============================================================================== Best regards Nick -+- Take care of the letter e! nick@mccme.ru Proton-S developer + Origin: http://nick.anihost.ru - select system (2:5020/194.118) ================================================================================ Press RESET immediately, All!