Author Topic: Check file existance with relative path  (Read 2300 times)

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Check file existance with relative path
« on: November 27, 2018, 12:34:39 AM »
There are many ways to check if a file exists: one is

Code: [Select]
fe.path_test(fullpathfilename , PathTest.IsFile)

another is

Code: [Select]
try {file(fullpathfilename, "r" );return true;}catch(e){return false;}

Both work well if you have a full pathname but, AFAIK, they don't work on relative paths. You can get the AM working directory with FeConfigDirectory, which is fine, but I want to check if a file exists inside a folder of the current theme, without having to hardcode the theme name or having the user insert a variable with the theme full path.

Is there a way or a workaround to get at least the current theme folder name?

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Check file existance with relative path
« Reply #1 on: November 27, 2018, 12:47:27 AM »
I'm an idiot: the solution was hiding in plain sight:

fe.script_dir

:D