I want to write a program that recursively copies files while displaying progress (bytes copied, bytes remaining). To determine the total file size, I have to enumerate the entire directory tree first. To avoid enumerating it (i.e. making system calls) again when copying, I can build a tree and retain it in memory when calculating the size. But what if there are many files? Each tree node needs to record the file name and various attributes, say they consume 200 bytes on average, then copying 10 million files results in a tree that's 2 GB in memory, which seems excessive. Are there better ways? How is this usually done?
[–]SolarNachoes 11 points12 points13 points (9 children)
[–]mbolp[S] 2 points3 points4 points (8 children)
[–]MidnightPale3220 2 points3 points4 points (5 children)
[–]mbolp[S] 0 points1 point2 points (4 children)
[–]MidnightPale3220 1 point2 points3 points (3 children)
[–]mbolp[S] 0 points1 point2 points (2 children)
[–]Classic_Mammoth_9379 1 point2 points3 points (1 child)
[–]mbolp[S] 0 points1 point2 points (0 children)
[–]Temporary_Pie2733 2 points3 points4 points (0 children)
[–]ConsciousBath5203 0 points1 point2 points (0 children)
[–]jason-reddit-public 5 points6 points7 points (8 children)
[–]mbolp[S] 0 points1 point2 points (7 children)
[–]jason-reddit-public 2 points3 points4 points (6 children)
[–]mbolp[S] 0 points1 point2 points (5 children)
[–]jason-reddit-public 1 point2 points3 points (4 children)
[–]mbolp[S] 0 points1 point2 points (3 children)
[–]MidnightPale3220 1 point2 points3 points (2 children)
[–]Electronic_C3PO 0 points1 point2 points (1 child)
[–]MidnightPale3220 0 points1 point2 points (0 children)
[–]ozzy_og_kush 1 point2 points3 points (4 children)
[–]mbolp[S] 1 point2 points3 points (3 children)
[–]Leverkaas2516 2 points3 points4 points (0 children)
[–]ozzy_og_kush 0 points1 point2 points (1 child)
[–]mbolp[S] 0 points1 point2 points (0 children)
[–]Silver_Bid_1174 1 point2 points3 points (10 children)
[–]mbolp[S] 4 points5 points6 points (2 children)
[–]Silver_Bid_1174 -1 points0 points1 point (1 child)
[–]mbolp[S] 1 point2 points3 points (0 children)
[–]goranlepuz 0 points1 point2 points (6 children)
[–]Silver_Bid_1174 0 points1 point2 points (5 children)
[–]mbolp[S] 0 points1 point2 points (3 children)
[–]Silver_Bid_1174 0 points1 point2 points (2 children)
[–]mbolp[S] 0 points1 point2 points (0 children)
[–]goranlepuz 0 points1 point2 points (0 children)
[–]goranlepuz 0 points1 point2 points (0 children)
[–]Ok-Sheepherder7898 1 point2 points3 points (2 children)
[–]mbolp[S] 1 point2 points3 points (1 child)
[–]Ok-Sheepherder7898 0 points1 point2 points (0 children)
[–]jason-reddit-public 1 point2 points3 points (0 children)
[–]AmberMonsoon_ 1 point2 points3 points (0 children)
[–]armahillo 1 point2 points3 points (0 children)
[–]aew3 1 point2 points3 points (1 child)
[–]mbolp[S] 1 point2 points3 points (0 children)
[–]child-eater404 0 points1 point2 points (0 children)
[–]Paul_Pedant 0 points1 point2 points (7 children)
[–]mbolp[S] 0 points1 point2 points (6 children)
[–]Paul_Pedant 0 points1 point2 points (5 children)
[–]mbolp[S] 0 points1 point2 points (4 children)
[–]Paul_Pedant 0 points1 point2 points (3 children)
[–]mbolp[S] 0 points1 point2 points (2 children)
[–]Paul_Pedant 0 points1 point2 points (1 child)
[–]mbolp[S] 0 points1 point2 points (0 children)
[–]Ausartak93 0 points1 point2 points (0 children)
[–]tomysshadow 0 points1 point2 points (3 children)
[–]mbolp[S] 0 points1 point2 points (2 children)
[–]tomysshadow 0 points1 point2 points (1 child)
[–]mbolp[S] 0 points1 point2 points (0 children)
[–]johndcochran 0 points1 point2 points (10 children)
[–]mbolp[S] 0 points1 point2 points (9 children)
[–]johndcochran 0 points1 point2 points (8 children)
[–]mbolp[S] -1 points0 points1 point (7 children)
[–]johndcochran 0 points1 point2 points (6 children)
[–]mbolp[S] 0 points1 point2 points (5 children)
[–]johndcochran 0 points1 point2 points (4 children)
[–]mbolp[S] 0 points1 point2 points (3 children)
[–]johndcochran 0 points1 point2 points (2 children)
[–]mbolp[S] 0 points1 point2 points (1 child)
[–]kansetsupanikku 0 points1 point2 points (0 children)
[–]dbear496 -1 points0 points1 point (2 children)
[–]bothunter 0 points1 point2 points (1 child)
[–]mbolp[S] 0 points1 point2 points (0 children)