Board index » cppbuilder » TIniFile - is it thread / process safe?

TIniFile - is it thread / process safe?


2006-04-26 04:12:24 AM
cppbuilder36
Hi,
If I have multiple threads or processes reading an ini file using the above
component (never writing), is this safe?
Paul
 
 

Re:TIniFile - is it thread / process safe?

Paul wrote:
Quote
Hi,

If I have multiple threads or processes reading an ini file using the
above component (never writing), is this safe?

Paul
If you only read the file, use TMemIniFile instead.
--
frode
 

Re:TIniFile - is it thread / process safe?

Is the benefit of this variant that on instantiating the component, that the
INI file is in memory and faster to read, and the TIniFile variant searches
the file every time?
My next question is not quite to do with INI files, but where to find them.
If I use GetCurrentDir (and SetCurrentDir), what does this actually mean, is
it scoped to Windows, just the application, and what if its used by a DLL?
What I want is the INI file to be located in the directory of the
application or DLL, and not in the Windows directory; I don't want to hard
code where to find it.
Paul
"Frode Nilsen" < XXXX@XXXXX.COM >wrote in message
Quote
Paul wrote:

>Hi,
>
>If I have multiple threads or processes reading an ini file using the
>above component (never writing), is this safe?
>
>Paul

If you only read the file, use TMemIniFile instead.

--
frode

 

{smallsort}

Re:TIniFile - is it thread / process safe?

Paul wrote:
Quote
My next question is not quite to do with INI files, but where to find them.
It is completely up to you to decide where your program stores it's ini file(s).
Quote
If I use GetCurrentDir (and SetCurrentDir), what does this actually mean,
That will give the last directory where a fileaction has been done by your
program. When you use relative paths then that info is important. But you
better use absolute paths.
Quote
What I want is the INI file to be located in the directory of the
application or DLL,
Very good.
Then, if you give the inifile the same name as your program,:
AnsiString IniFileName = ChangeFileExt ( ParamStr(0), ".ini" );
Quote
and not in the Windows directory;
Very good.
Hans.
 

Re:TIniFile - is it thread / process safe?

Thanks.
Quote
Then, if you give the inifile the same name as your program,:

AnsiString IniFileName = ChangeFileExt ( ParamStr(0), ".ini" );

 

Re:TIniFile - is it thread / process safe?

Paul wrote:
Quote
"Frode Nilsen" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>Paul wrote:
>
>>
>>If I have multiple threads or processes reading an ini file using
>>the above component (never writing), is this safe?
>>
>If you only read the file, use TMemIniFile instead.
>
Is the benefit of this variant that on instantiating the component,
that the INI file is in memory and faster to read, and the TIniFile
variant searches the file every time?
The benefit is that you don't lock the file, or have update conflicts
with other's reading/writing the same file.
Quote

What I want is the INI file to be located in the directory of the
application or DLL, and not in the Windows directory; I don't want to
hard code where to find it.

ExtractFilePath(Application->ExeName) + "filename.ini" should do the
trick
--
frode
 

Re:TIniFile - is it thread / process safe?

Thanks everyone.
Quote
ExtractFilePath(Application->ExeName) + "filename.ini" should do the
trick

--
frode