Chocolate Quest Repoured

Chocolate Quest Repoured

2M Downloads

Incorrect path separators on Linux

mphe opened this issue ยท 7 comments

commented

Describe the bug
I'm running a 1.12.2 server on Linux with the current version of this mod (Alpha 18.2).
I noticed several files containing backslashes in their names. Since Linux (and MacOS) use normal forward slashes as path separators, these files are located in the wrong directories and have the intended path as filename.

For example, in the server folder there's, next to the usual world directory, another world\ directory.
In world there are some more files with the following filenames:

data\cqr_structure_parts.nbt
DIM-11325\data\cqr_structure_parts.nbt
DIM-1\data\cqr_structure_parts.nbt
DIM1\data\cqr_structure_parts.nbt
DIM7\data\cqr_structure_parts.nbt
DIM800\data\cqr_structure_parts.nbt
DIM801\data\cqr_structure_parts.nbt
DIM802\data\cqr_structure_parts.nbt
DIM803\data\cqr_structure_parts.nbt
DIM804\data\cqr_structure_parts.nbt
DIM805\data\cqr_structure_parts.nbt
DIM806\data\cqr_structure_parts.nbt
DIM807\data\cqr_structure_parts.nbt
DIM808\data\cqr_structure_parts.nbt
DIM809\data\cqr_structure_parts.nbt
DIM810\data\cqr_structure_parts.nbt
DIM811\data\cqr_structure_parts.nbt
DIM812\data\cqr_structure_parts.nbt
DIM813\data\cqr_structure_parts.nbt
DIM814\data\cqr_structure_parts.nbt
DIM815\data\cqr_structure_parts.nbt
DIM816\data\cqr_structure_parts.nbt
DIM817\data\cqr_structure_parts.nbt
DIM818\data\cqr_structure_parts.nbt
DIM819\data\cqr_structure_parts.nbt
DIM820\data\cqr_structure_parts.nbt
DIM821\data\cqr_structure_parts.nbt
DIM-9999\data\cqr_structure_parts.nbt

Expected behavior
Path separators should not be hardcoded, but handled platform dependant.

To Reproduce
Setup a Minecraft server on Linux with this mod and run the server.

Versions
Chocolate Quest Repoured: A18.2
Forge: forge-1.12.2-14.23.5.2846-universal
Minecraft: 1.12.2

commented

Thanks for fixing, and for reviving this great mod!

commented

Blame java for this or your installation. I ran it on a linux server too and it was just fine and acted like supposed. However this was before someone changed the path entries. Will take a look at the related code

commented

I noticed that aswell ; it indeed create errors because the the files are then not found... I had to manually create the files for the errors to be gone.

Thanks for looking into it ! :)

commented

Blame java for this or your installation.

My setup is fine, it's just regular, up-to-date java with regular forge.
Removing other mods, the list of incorrect files is shorter, due to less dimensions, but still same bug.

data\cqr_structure_parts.nbt
DIM-1\data\cqr_structure_parts.nbt
DIM1\data\cqr_structure_parts.nbt
world\

I ran a quick grep -RI '\\' src, showing several files with hardcoded backslashes.

src/main/java/com/teamcqr/chocolatequestrepoured/structuregen/generation/DungeonGenerationHandler.java:			this.file = new File(world.getSaveHandler().getWorldDirectory(), "data\\cqr_structure_parts.nbt");
src/main/java/com/teamcqr/chocolatequestrepoured/structuregen/generation/DungeonGenerationHandler.java:			this.file = new File(world.getSaveHandler().getWorldDirectory(), "DIM" + dim + "\\data\\cqr_structure_parts.nbt");
src/main/java/com/teamcqr/chocolatequestrepoured/structuregen/generators/castleparts/rooms/CastleRoomSelector.java:		System.out.format("Placing tower at %d,%d on floor %d facing %s, size = %d\n", x, z, startFloor, alignment.toString(), towerSize);
src/main/java/com/teamcqr/chocolatequestrepoured/structureprot/ProtectionHandler.java:            regionsToBeZipped.put("dim_" + dimID + "\\" + region.getUUIDString(), ObjectSerializationUtil.writeSerializableToByteArray(region));
src/main/java/com/teamcqr/chocolatequestrepoured/structureprot/ProtectionHandler.java:        FileIOUtil.saveToFile(FileIOUtil.getAbsoluteWorldPath() + "data\\CQR\\prot_region_defs.zip", ArchiveManipulationUtil.zip(regionsToBeZipped));
src/main/java/com/teamcqr/chocolatequestrepoured/structureprot/ProtectionHandler.java:        HashMap<String, byte[]> protectedRegionsFromDisc = ArchiveManipulationUtil.unzip(FileIOUtil.loadFromFile(FileIOUtil.getAbsoluteWorldPath() + "data\\CQR\\prot_region_defs.zip"));
src/main/java/com/teamcqr/chocolatequestrepoured/structureprot/ProtectionHandler.java:                while (regionFileName.charAt(dimIDAsStringCursorPos) != '\\') {
src/main/java/com/teamcqr/chocolatequestrepoured/util/DebugEntryPoint.java:		 * HashMap<String, byte[]> unzipped = ArchiveManipulationUtil.unzip(FileIOUtil.loadFromFile("S:\\Libraries\\Documents\\_Project Odin\\newmodworkspace\\_extern\\ChocolateQuestRepoured\\Forge Mapping Files for CQR.zip"));
src/main/java/com/teamcqr/chocolatequestrepoured/util/DebugEntryPoint.java:		 * FileIOUtil.saveToFile("S:\\Libraries\\Documents\\_Project Odin\\newmodworkspace\\_extern\\ChocolateQuestRepoured\\mappings\\" + fileName, unzipped.get(fileName));
src/main/java/com/teamcqr/chocolatequestrepoured/util/data/FileIOUtil.java:		return DimensionManager.getCurrentSaveRootDirectory() + "\\";
src/main/java/com/teamcqr/chocolatequestrepoured/util/data/ArchiveManipulationUtil.java:				HashMap<String, byte[]> recursiveReturn = unzip(namePrefix + "\\" + currentZipEntry.getName(), ByteArrayManipulationUtil.convertArrayListByteToPrimByteArray(buffer));
src/main/java/com/teamcqr/chocolatequestrepoured/objects/items/ItemDungeonPlacer.java:				String dependency = nbtTag.toString().replace("\"", "");
commented

ok the list of files is useful. I'll change it to the correct usage now (using '/' instead of '\') I hope the one that changed it to '\' doesnt revert it....

commented

will be fixed in next build.

commented

Should be fixed in newest versions