It's UWAweek 30 (2nd semester, week 1)

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 1168 articles.
Currently 9 other people reading this forum.


 UWA week 42 (2nd semester, week 12) ↓
SVG not supported

Login to reply

👍x2
helpful
3:22pm Mon 16th Oct, Christopher M.

ANONYMOUS wrote:
> In summary, my program stealthily copies and deletes any empty directories before it finishes, which does produce desired output of not syncing empty directories. I'm just wondering if this method is an acceptable method or if I've done it in a convoluted way.
Whether this approach is described as working silently, stealthily, or convoluted, you'd surely have to agree that it's inelegant? I can't think of many (any?) tasks in computing where we perform an activity, and then undo it later on to achieve the desired result. If this involved only manipulation of data in memory, then it'd be far more acceptable, but we've emphasised that accessing the file-system, potentially on a slow physical device, is best avoided if possible. If you think about what it means for a directory to be 'empty', then you really should be able to write a short function, fewer than 10 lines, to determine if a directory is empty. But if that function requires many trips to the file-system then it, too, is not a good approach.
> My reasoning for this, is that when pairing -n with -r, my program can only work recursively if it can see the directories to be sync'd in disk, and wouldn't work if I didn't silently copy empty directories then delete them after recursion.
I'm afraid that I'm unable to follow this reasoning - the -r option indicates how top-level directories (and possibly their subdirectories) should be traversed in search of files; the -n option indicates if we should actually copy the files if there is the need. There's nothing in that combination about directories being empty or not.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  7:24AM Jul 25 2024
Privacy policy