Page MenuHome

Linux: Double backslash in file path interpreted as path separator
Closed, ArchivedPublic

Description

System Information
Operating system: Ubuntu 20.04.2 LTS
Graphics card: Mesa Intel® UHD Graphics 630 (CFL GT2)

Blender Version
Broken: blender-2.91.2-linux64 from blender.org -- wrong filename
Broken: Blender 2.82.a+dfsg-1 from repos -- crashes (the crash might have been fixed in https://developer.blender.org/T74579)

Short description of error

A file named "example\\test.png" (2 backslashes) appears as "test.png" in the file browser and cannot be opened ("file not found").

Exact steps for others to reproduce the error

  1. Create a file named example\\test.png (two literal backslashes) in the home folder (/home/username/)
  2. Start blender with default project (cube)
  3. Switch to "UV Editing" mode
  4. Click on "open image"
  5. Navigate to the home folder

Expected result

  • "example\\test.png" appears in the file list and is selectable and can be opened

Actual result

  • "test.png" appears in the file list and opening it results in an error: "Cannot read '/home/username/example\\test.png': No such file or directory"

Event Timeline

Linux may permit backslashes in filenames, but Blender doesn't in this case. The fix rBec9b836d3b5634ed06c0ae5e2461731bc43f34bf for the referenced ticket T74579 contains the following comment:

/* This happens when a path contains 'ALTSEP', '\' on Unix for e.g.
  * Supporting alternate slashes in paths is a bigger task involving changes
  * in many parts of the code, for now just prevent an assert, see T74579. */

A filename with backslashes also would not be valid on Windows, which could cause issues when moving projects across operating systems.

@Campbell Barton (campbellbarton) this is a known issue and the ticket can be closed, correct?

I totally agree with @Robert Guetzkow (rjg). Having characters in your file name that aren't allowed on certain operating systems is problematic, but using a Windows path separator as part of the filename is an actual Bad Idea™.
Of course Blender can implement OS-specific workarounds, but when the underlying OS doesn't support it (or worse: mis-treats the file), you're likely to end up in a world of pain.

Anecdote: Linux Mint's screenshot tool used to format their datetimes with actual colons in the file name, which is allowed on Linux, but not on Windows. Also my NAS at the time would accept filenames like this via rsync, but wouldn't let me do anything with the file afterwards, it was extremely complicated to rename the file back to working condition. Linux Mint later changed the naming convention from colons to dashes, because this was causing problems all over the place.

@Robert Guetzkow (rjg) right, even if we wanted to change this convention, it would be a TODO (as the current code works as intended).

We could have a new section in https://docs.blender.org/manual/en/latest/advanced/index.html that details path handling limits, what is/isn't supported.

Although this doesn't seem very high priority.

This report can be closed.