You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactoring: Fix handling of slashes - "/" vs "\" #1121
Currently cross-platform handling of paths with Windows-like and Unis-like slashes deserves to be better.
There are a lot of calls to FileSystem::fix_slashes() function scattered around to handle correct handling of file paths. Currently this converts all (almost all) "\" slashes to "/". This needs to be refactored.
Here how I think things should be:
Internally Synfig should use unis-like slashes ("/") everywhere - in code and in saved XML files.
On Windows, when displaying some path in GUI widgets it should convert slashes to windows-like (when exposing into widget) and convert from windows-like to unis-like (when gathering path from widget).
Some info to consider:
In Python there are a set of specific functions to handle path operations (in os.path).
Currently cross-platform handling of paths with Windows-like and Unis-like slashes deserves to be better.
There are a lot of calls to `FileSystem::fix_slashes()` function scattered around to handle correct handling of file paths. Currently this converts all (almost all) "\" slashes to "/". This needs to be refactored.
why almost? how this code can skip one?
for(size_t i = 0; i < fixed.size(); ++i)
if (fixed[i] == '\\') fixed[i] = '/';
Here how I think things should be:
Internally Synfig should use unis-like slashes ("/") everywhere - in code and in saved XML files.
On Windows, when displaying some path in GUI widgets it should convert slashes to windows-like (when exposing into widget) and convert from windows-like to unis-like (when gathering path from widget).
Some info to consider:
* In Python there are a set of specific functions to handle path operations (in `os.path`).
* QT has a special class QFileInfo - https://doc.qt.io/archives/qt-4.8/qfileinfo.html
* I wonder, how this handled in OpenToonz?
ping @blackwarthog
Windows supports '/' from XP, and XP already is not supported by us and is not supported my Microsoft (Vista, 7 also in the past, 8 almost)
I suggest to always use '/'
FileSystem::fix_slashes required for zip files (only '/' is correct for zip), but to make zip-fs layer full integrated we need to use common rules for whole file system. To avoid situation where one instance of FileSystem (native, temporary, group, etc) takes '\' and returns '\' but another instance (zip) when takes '\' but returns '/'. So valid solution where any type and any instance of FileSystem always converts slashes to '/'.
Proper solution is to add code from fix_slashes() into etl::cleanup_path() and replace fix_slashes to cleanup_path.
Activity
rodolforg commentedon Jan 25, 2020
blackwarthog commentedon Jan 25, 2020