Author Topic: Problem with FileExists on Ubuntu  (Read 833 times)

0 Members and 1 Guest are viewing this topic.

Offline Railor

  • Major(1)
  • Posts: 16
Problem with FileExists on Ubuntu
« on: March 26, 2008, 03:48:58 pm »
Hi everybody!
I'm currently working on a SubAdmin script, which uses FileExists. On my Windows server the following snippet works fine
Code: [Select]
if FileExists('SubAdmin/Admins/'+filterFilename(Name)+'.txt') then
begin
//...
end else
writeConsole(ID,'Account doesn''t exists!',$FF0000);
//...
but if I try the same script, with the same files on an ubuntu server, it always says "Account doesnt exists".
I tried it also without filterFilename, but the same result.
Anyboy have a idea?
« Last Edit: March 26, 2008, 03:51:28 pm by Railor »


Offline Railor

  • Major(1)
  • Posts: 16
Re: Problem with FileExists on Ubuntu
« Reply #2 on: March 26, 2008, 04:14:46 pm »
YES! That's it!
Thanks a lot  ;D

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Problem with FileExists on Ubuntu
« Reply #3 on: March 26, 2008, 08:30:31 pm »
Actually, I've found out the problem has to do with paths; under Linux (for security reasons) the current path is never used when opening files, which means that the file you open should be either './SubAdmin/Admins/...' or the fully qualified path to the file ('/home/<name>/soldatserver/SubAdmin/Admins/...' or equivilant) depending on how you start the server. Windows always searches the current path when opening files.

The reason everything else works without proper paths is because the FileExists function is mapped directly to Delphi's FileExists function, and the other file functions are wrappers around the functions because they require additional processing; the wrappers append the actual path to the server onto the files path.


This will be fixed in the next server release (which will probably coincide with 1.5.0)
« Last Edit: March 26, 2008, 08:38:45 pm by chrisgbk »

Offline Railor

  • Major(1)
  • Posts: 16
Re: Problem with FileExists on Ubuntu
« Reply #4 on: March 27, 2008, 06:00:26 am »
Yeah, I got also problems with ReadFile, I will try it with
'/home/<name>/soldatserver/SubAdmin/Admins/...'
Thanks a lot, too.  :)