annotate matlab/db/uniquefile.m @ 37:89688ebc447f tip

Deprecating this repository.
author samer
date Mon, 05 Jan 2015 17:42:03 +0000
parents 0dd31a8c66bd
children
rev   line source
samer@0 1 function fn=uniquefile(dt,root,dir,pattern)
samer@0 2 % uniquefile - Allocate a unique unused filename
samer@0 3 %
samer@0 4 % uniquefile ::
samer@0 5 % [[1,6]] ~'date as returned by clock (currently not used)',
samer@0 6 % path ~'implicit root directory',
samer@0 7 % path ~'explicit directory relative to implicit root',
samer@0 8 % string ~'filepath pattern with exactly one %s somewhere to accept id'
samer@0 9 % -> path ~'unique path relative to implicit root'.
samer@0 10
samer@0 11 % SA 2005-04-25 Seems that 10000 files per directory is not enough..
samer@0 12 % SA 2008-06-27 Pattern must now contain %s, not %d.
samer@0 13
samer@0 14 exists=1;
samer@0 15 numpat=sprintf(pattern,'%05d');
samer@0 16 while exists,
samer@0 17 fn=fullfile(dir,sprintf(numpat,floor(100000*rand)));
samer@0 18 exists=exist(fullfile(root,fn),'file');
samer@0 19 end
samer@0 20
samer@0 21