home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,506 of 2,978   
   Dr J R Stockton to All   
   Re: Long filename support in Windows Vis   
   23 Aug 07 20:05:19   
   
   From: jrs@merlyn.demon.co.uk   
      
   In comp.lang.pascal.borland message <1187883289.124454.112390@q3g2000prf   
   .googlegroups.com>, Thu, 23 Aug 2007 08:34:49, Jim Leonard   
    posted:   
   >   
   >Here's what I'm trying to write:  A friend has asked me for a utility   
   >that will take a size parameter (like "700MB") and copy random files   
   >from a source directory (including recursing to subdirectories) to a   
   >target directory.  This is so he can randomly fill things like his   
   >music player or his digital picture frame with new content every day.   
   >   
   >My idea was to write it in TP, since it's very quick for me to write a   
   >small utility like this in TP, but then I thought of the following:   
      
   >- Memory.  Using my own MP3 collection as a testbed, I have over 9700   
   >music files.  Assuming an average directory depth+name of 64 bytes,   
   >building a list of the available files to copy would exceed the 640K   
   >RAM available.  So a Win32 compiler is an option simply so I have more/   
   >virtual memory available.   
      
   ISTM that you don't need to store all that.  It seems safe to disregard   
   the possibility that, during the copying, the candidate file set will be   
   changed.   
      
   First, scan the whole target area, counting (from 0 to N) the eligible   
   files.   
      
   Now choose file numbers in that range at random, and for each choice   
   scan again up to that number, and note in an ordered list the number and   
   maintain the accumulated size.  Repeat, but check in the list for   
   duplicates, until the target size is more-or-less reached.  Some minor   
   refinements may be needed, but that should solve the storage problem.   
      
   The scans subsequent to the first will probably read from cache, so   
   should be quick.   
      
   If you know that you have 700 MB to fill, and no files are bigger than   
   50 MB, then you can generate 14 randoms and do all in one scan, if that   
   helps; then see how much space is left, and iterate.   
      
   Untested.   
      
   --   
    (c) John Stockton, Surrey, UK. *@merlyn.demon.co.uk / ??.Stockton@physics.org   
    Web   - FAQish topics, acronyms, & links.   
    Correct <= 4-line sig. separator as above, a line precisely "-- " (SoRFC1036)   
    Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca