On Tue, 20 Jan 2009, Lorenzo Fiorini wrote: > I'm getting some errors with temporary files used to sort or index ( > though in a stress test ).
Probably you generated non unique file names for them. You will have to change your code. > What's the best way to get a unique temporay file in the same dir that > work in *nix, osx and win that work in a mt app? For indexes simply use TEMPORARY clause, f.e.: INDEX ON ... TEMPORARY Such indexes will be created in temporary files or in memory if RDD decides it's better and on close any temporary files will be removed. They are always accessed in exclusive mode even if workarea is shared what also improve the speed. We do not have support for TEMPORARY tables yet so here you will have to generate unique file name. The procedure which makes it should always create empty physical file otherwise you will have race condition between generating unique name with checking if it does not exist and creating the table. In theory we can use hb_FTempCreate() but because it does not allow to control file name extensions then it may be a little bit problematic so I suggest to create own function and use FO_EXCL flag with HB_FCREATE(), f.e. sth like: function MK_TMPFILE( cDir ) local hFile, cName, nTry := 0 while ++nTry < 10000 cName := cDir + [...] + ".tmp" // gen unique file name with extension hFile := hb_FCreate( cName,, FO_EXCLUSIVE + FO_EXCL ) if hFile != -1 FClose( hFile ) return cName endif enddo return nil It's not 100% safe method because FO_EXCL flag cannot be supported without race condition on remote systems (f.e. NFS mounted volumes) but for such usage like in your case it's enough. best regards, Przemek _______________________________________________ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour