Re: [Lazarus] Safe temp file name

2015-11-25 Thread Graeme Geldenhuys
On 2015-11-25 15:41, Rik van Kekem wrote: > Why are the { and } actually removed? > > As far as I know they can be part of a filename on all OSes (or am I wrong?) In tiOPF (the code I linked too), GUID's are used as an OID (Object ID), and normally stored in a database field of type char(36). The

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Henry Vermaak
On Wed, Nov 25, 2015 at 05:51:41AM -0800, Aradeonas wrote: > Hi, > > I used GetTempFileName in a multi thread system and it causes problems > as you guess already. So the best way in my mind is using GUID and maybe > use it in a loop for checking not existing for extra safety. But I want > to know

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Rik van Kekem
Graeme Geldenhuys wrote: Oops, my mistake. Yes, only { and } is removed in tiOPF code. Why are the { and } actually removed? As far as I know they can be part of a filename on all OSes (or am I wrong?) Grtz, Rik (rvk) -- ___ Lazarus mailing list Laz

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Graeme Geldenhuys
On 2015-11-25 15:27, Aradeonas wrote: >> > if (LValue[1] = '{') and(LValue[cGUIDLength] = '}') thenLValue >> > := Copy(lValue, 2, cGUIDLength - 2); AAssignTo.AsString := LValue; > It seems it doesnt remove "-" . > Oops, my mistake. Yes, only { and } is removed in tiOPF code. Regards,

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Aradeonas
Thanks Graeme,Its like what I do so it seems Im doing OK. I looked at the code and it seems it just remove { and }. > if (LValue[1] = '{') and    (LValue[cGUIDLength] = '}') then    LValue > := Copy(lValue, 2, cGUIDLength - 2);  AAssignTo.AsString := LValue; It seems it doesnt remove "-" . > This

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Rik van Kekem
Rik van Kekem wrote: (I'm not sure if FPC 2.6.4 also some helpers for creating GUIDs) This will work in FPC 2.6.4: var GUID : TGUID; begin if CreateGUID(GUID) = 0 then begin MyFileName := GuiDToString(Guid); end; You could strip the {, } and - if you want. Grtz, Rik (rvk) -- ___

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Rik van Kekem
Aradeonas wrote: > I used GetTempFileName in a multi thread system and it causes problems > as you guess already. I wasn't aware that GetTempFileName isn't threadsafe. (Are you sure your code is correct?) Graeme Geldenhuys wrote: On 2015-11-25 13:51, Aradeonas wrote: So the best way in my mind

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Tony Whyman
This may be an appropriate use for EnterCriticalSection and ExitCriticalSection, although why don't you just use a different "prefix" in the call to GetTempFile for each thread. On 25/11/15 13:51, Aradeonas wrote: Hi, I used GetTempFileName in a multi thread system and it causes problems as y

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Graeme Geldenhuys
On 2015-11-25 14:50, Aradeonas wrote: > Can you point me to where this system > implemented in tiOPF? This function returns a GUID value: http://sourceforge.net/p/tiopf/code/ci/tiopf2/tree/Core/tiUtils.pas#l3837 This is the class in tiOPF that uses GUID's. This class strips out the '{', '-' an

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Aradeonas
Thank you Graeme. Can you point me to where this system implemented in tiOPF? Regards, Ara -- http://www.fastmail.com - The professional email service -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.or

Re: [Lazarus] Safe temp file name

2015-11-25 Thread Graeme Geldenhuys
On 2015-11-25 13:51, Aradeonas wrote: > So the best way in my mind is using GUID and maybe > use it in a loop for checking not existing for extra safety. I've used GUID's as temp file names in a CGI application for about 5 years. The CGI app gets accessed all at the same time in a classroom enviro

[Lazarus] Safe temp file name

2015-11-25 Thread Aradeonas
Hi, I used GetTempFileName in a multi thread system and it causes problems as you guess already. So the best way in my mind is using GUID and maybe use it in a loop for checking not existing for extra safety. But I want to know is there any clean implementation already that I dont know of? Regard