0

I use Inno Setup 5 to create an ini file with {app} as the destination:

[INI]
Filename: "{userdocs}\JavaCppDemo.ini"; Section: "InstallSettings"; Flags: uninsdeletesection
Filename: "{userdocs}\JavaCppDemo.ini"; Section: "InstallSettings"; Key: "InstallPath"; String: "{app}"

Then I use ini4j to get the value of InstallPath:

String DefaultFolder = new FileChooser().getFileSystemView().getDefaultDirectory().toString(); 

// tricky way of getting at user/documents folder
String strFileName = DefaultFolder + "\\JavaCppDemo.ini";
Ini ini = null;

try {
   ini = new Ini(new File(DefaultFolder + "\\JavaCppDemo.ini"));
} catch (IOException ex) {
   Logger.getLogger(CppInterface.class.getName()).log(Level.SEVERE, null, ex);
}

String strDatafile;
Ini.Section section = ini.get("InstallSettings");
String installPath = section.get("InstallPath");

The problem installPath gets set to C:UsersEd SowellDocumentsJavaCppDemoLog.txt.

IOW, the path element separator \ gets stripped out.

Since the value of {app} is selected by the user with FileChooser when the setup is executed , I don't have the option of changing it.

Is this a known incompatibility between Inno-Setup and ini4j?

Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
Ed S
  • 239
  • 5
  • 21
  • This should help you http://stackoverflow.com/q/25001453/960757, I guess. And there is nothing like incompatibility between Inno Setup and ini4j. They have no relation at all. Inno Setup just stores the path and you are reading it. – TLama Jun 04 '15 at 18:51
  • I tried the Config.getGlobal().setEscape(false); but it did nothing. Also, the post and answers are confusing. E.g., if the problem is a total absence of backslashes I don't see why the poster & commenters are talking about replacing them. – Ed S Jun 04 '15 at 20:14
  • Yes, that's nonsense (how could one replace something that is not present). But anyway, you have only two options here. Either you'll save the value so that ini4j will be able to read it correctly (which is I guess if you double all backslashes in the path), or setup the ini4j to read it. I could help you only with the first option. – TLama Jun 04 '15 at 20:21
  • Also, if program A (in this case Inno Setup) outputs code that is supped to work with program B (in this case ini4j) but doesn't, I'd be inclined to call it an incompatibility. Or, is there an error in my code? – Ed S Jun 04 '15 at 20:21
  • If you could show me how to make Inno setup write the value {app} with \\ instead of \ it might help, but I'm not sure. For example, I changed the ini file with a text editor to have \\ but ini4j still wan't happy. – Ed S Jun 04 '15 at 20:26
  • 1
    Shouldn't you use `Wini` class instead of `Ini` (they are doing so in [`this tutorial`](http://ini4j.sourceforge.net/tutorial/OneMinuteTutorial.java.html) saying that it's for Windows INI files) ? – TLama Jun 04 '15 at 20:31
  • perhaps... BTW, I misspoke. when I manually change to \\ is is read by ini4j – Ed S Jun 04 '15 at 20:50
  • 1
    Ok, seems you don't care. So you just want to intentionally break that Windows path. Well, it's upon you. Here is [`your code`](http://pastebin.com/dZXg0Y09). – TLama Jun 04 '15 at 21:05
  • 1
    Thanks & Thanks. First, you are right, Wini does the trick. I have seen examples using ini and "\" so thought ini was worked for WIndows too. Did not even know about Wini. Second, thanks for the [code] example. Long time since I've seen Pascal! – Ed S Jun 05 '15 at 13:01

0 Answers0