Apr 072009
 

I was trying to figure out how to load a file from the path where the executable stays, the first thing came to my mind is using Win32’s GetCommandLine, and then do GetFullPathName. It seems ideal in C/C++ world but obviously things don’t work quite well in Ada, especially delimiter changed from / to and then changed back, I have no idea what does Ada’s run-time library is doing.

Then I found Ada has this package – Ada.Directories, it is actually what I want. Using GetCommandLine to get the executable’s full path name, and use Ada.Directories.Containing_Directory to get the directory, all set.

This got me recall similar things in C/UNIX, though UNIX API can do whatever I want, it is usually convenience to use C functions as it fit the language well. Things are getting worse with Ada on Windows, since we all know Windows was not developed by Ada …

BTW, Ada’s identifier is really long, and actually this is the style I’m trying to follow.

  2 Responses to “Language feature is better than OS”

  1. Turned out I should not even use GetCommandLine, as it behaves differently when starting from command line or double click in explorer.

    I changed to use Ada.Command_Line.Command_Name then everything’s working fine now.

  2. I think I need to spend more time on reading Ada documentation so to know more packages that can be used, after all programming is just put those functions together.

Sorry, the comment form is closed at this time.