Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rom_path getting corrupted in wabbitemu.ini (Windows) #36

Open
milnak opened this issue Apr 19, 2022 · 2 comments
Open

rom_path getting corrupted in wabbitemu.ini (Windows) #36

milnak opened this issue Apr 19, 2022 · 2 comments

Comments

@milnak
Copy link

milnak commented Apr 19, 2022

I'm seeing this in wabbitemu.ini when I set portable mode:

rom_path=C:\Users\jeffm\Downloads\wabbitemuwabbitemu.sav

A cursory look at the source code looks like it may be occurring here:

TCHAR tempSave[MAX_PATH] = {0};
if (portable_mode) {
	StringCbCopy(tempSave, sizeof(tempSave), portSettingsPath);
	for (u_int i = _tcslen(portSettingsPath) - 1; i >= 0; i--) {
		if (tempSave[i] == '\\') {
			tempSave[i] = '\0';
			break;
		}
		tempSave[i] = '\0';
	}
} else {
	GetStorageString(tempSave, sizeof(tempSave));
}
StringCbCat(tempSave, sizeof(tempSave), _T("wabbitemu.sav"));
StringCbCopy(lpCalc->rom_path, sizeof(lpCalc->rom_path), tempSave);

this code is putting settings path into tempSave and removing any trailing slash. it then concatenates wabbitemu.sav, but the trailing slash should be retained so that we end up with <portSettingsPath>\wabbitemu.sav

nit 1: the loop should reference _tcslen(tempSave), not portSettingsPath. While they're equivalent, the code in the loop is operating on tempSave.

nit 2: tempSave isn't needed. All operations here can use lpCalc->rom_path directly.

@milnak
Copy link
Author

milnak commented Apr 19, 2022

Note that GetStorageString seems inconsistent as well. In WINDOWS it returns %APPDATA%\Wabbitemu\ (with trailing slash), but on unix it returns ~/.wabbitemu (no trailing slash)

@milnak
Copy link
Author

milnak commented Apr 20, 2022

I believe the fix is:

		// portSettingsPath is "{path}\wabbitemu.ini" -- remove the filename, but keep trailing backslash.

		if (tempSave[i] == '\\') {
			tempSave[i+1] = '\0';
			break;
		}
	}
} else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant