ANONYMOUS wrote:
> Would it ever be the case that our mysync program is run with two directories of the form below:
> ....
> In this example, I am not too sure what would happen as it is not really able to be done on the sample solution. Is it alright to assume that, due to this, it would not be assessed?
I'm unsure why (it's very notable that) this case has generated as much discussion/confusion as it has. Yes, it's a valid/reasonable case that could be assessed.
Here is a shellscript of commands to build a set of test directories and files. It uses the
tree
command to provide a visual recursive listing of the directories before and after synchronisation:
#/bin/bash
rm -rf dir1
#
mkdir dir1
date > dir1/file1
cal > dir1/file2
#
mkdir dir1/dir2
ls > dir1/dir2/file3
#
echo "before syncing:"
tree dir1
tree dir1/dir2
echo "____________________________"
#
./mysync dir1 dir1/dir2
echo "after syncing:"
tree dir1
tree dir1/dir2
#
rm -rf dir1
and its output when executed.
A copy of each file below dir1 is made within dir1/dir2, and a copy of each file below dir1/dir2 is made within dir1.
before syncing:
dir1
|-- dir2
| `-- file3
|-- file1
`-- file2
2 directories, 3 files
dir1/dir2
`-- file3
1 directory, 1 file
____________________________
after syncing:
dir1
|-- dir2
| |-- file1
| |-- file2
| `-- file3
|-- file1
|-- file2
`-- file3
2 directories, 6 files
dir1/dir2
|-- file1
|-- file2
`-- file3
1 directory, 3 files
and if we change the script to run
./mysync -r
(recursively) we get:
before syncing:
dir1
|-- dir2
| `-- file3
|-- file1
`-- file2
2 directories, 3 files
dir1/dir2
`-- file3
1 directory, 1 file
____________________________
after syncing:
dir1
|-- dir2
| |-- dir2
| | `-- file3
| |-- file1
| |-- file2
| `-- file3
|-- file1
|-- file2
`-- file3
3 directories, 7 files
dir1/dir2
|-- dir2
| `-- file3
|-- file1
|-- file2
`-- file3
2 directories, 4 files