PolyGlot icon indicating copy to clipboard operation
PolyGlot copied to clipboard

Refactor Working Directory to OS-specific locations

Open synthfi opened this issue 4 months ago • 2 comments

Changes

  • getWorkingDirectory was split into: getConfigDirectory, getStateDirectory, and getTempDirectory
    • in each of the returned directories, a PolyGlot folder is created
    • The original functionality of unit tests using PolyGlot_TEST instead of PolyGlot is kept
Function Linux Path Windows Path OSX Path
getConfigDirectory() $XDG_CONFIG_HOME
or ~/.config
%LOCALAPPDATA% ~/Library/Preferences
getStateDirectory() $XDG_STATE_HOME
or ~/.local/cache
%LOCALAPPDATA% ~/Library/Application Support
getTempDirectory() $XDG_CACHE_HOME
or ~/.local/state
%TEMP% ~/Library/Caches
  • general refactors to use java.nio.file.Path instead of String & File
  • updated tests
  • getErrorLogFile can now throw IOException
  • Unzipping of readme.zip is still done in a system temp directory as the designers of snap decided that snap packages should not be able to open files in hidden directories.
  • Updated the About menu to list the locations of the config, state, and temp directories

Notes

  • config is used for PolyGlot.ini. state is used for: autosave file, error log, webservice files (in sub-directory called WebServices). temp is used for: temp files (csv <-> excel), ...
  • This brings understanding of the XDG base directory specification into PolyGlot. I tried my best to map these locations to windows & macos while keeping the source code simple. Please correct me if any of this is wrong.
  • This is a stepping stone towards distribution as flatpak. This is the primary motivation behind this pr

Draft:

  • [x] Add/update help menu to show what paths the app is using
  • [x] update for creation of temp files for various things
  • [ ] manually test excel file opening
  • [ ] manually test font import file opening
  • [ ] manually test logo import file opening
  • [ ] manually test webservice file opening
  • [ ] manually test print 2 pdf file opening
  • [x] run tests on windows
  • [x] run tests on macOS

Closes https://github.com/DraqueT/PolyGlot/issues/1349

synthfi avatar Oct 26 '24 18:10 synthfi