Getting the "launch" dir
Posted: Sat Mar 30, 2019 10:07 am
I have programs that take an input file as a command line argument, and if the file is given without a path (the input file is in the same dir with a Hollywood program, or you launch the Hollywood program from elsewhere like SYS:Applications/MyProgram filetobeopened.txt), Hollywood doesn't find the file because current directory is changed to the location of the Hollywood program. If the program also needs data files from its directory, disabling the automatic directory changing isn't a solution alone.
I didn't find any command from Hollywood to get the directory the program was initially launched, but is there anything for that?
I just made a work-around for it now like this:
1) Enable the NoChDir option
2) Store the current directory with the GetCurrentDirectory()
3) Use the GetProgramInfo() to get the program directory
4) Change the current directory manually to the program dir with the ChangeDirectory() function
5) Handle the file opening with the stored dir if the file doesn't contain a path
So, it would be much more convenient to have a function, or some other way, to get the directory the program was launched from.
I didn't find any command from Hollywood to get the directory the program was initially launched, but is there anything for that?
I just made a work-around for it now like this:
1) Enable the NoChDir option
2) Store the current directory with the GetCurrentDirectory()
3) Use the GetProgramInfo() to get the program directory
4) Change the current directory manually to the program dir with the ChangeDirectory() function
5) Handle the file opening with the stored dir if the file doesn't contain a path
So, it would be much more convenient to have a function, or some other way, to get the directory the program was launched from.