A Tcl module to simplify cross-platform application file locations
An application that is installed on a variety of platforms will use different locations on each platform to access files. This module aims to provide access to these locations through a common interface. For each operating system the module aims to use an appropriate standard for the locations, for example on Linux the XDG Base Directory Specification is used and on Microsoft Windows the most common locations for each version of the operating system is used.
- Tcl 8.6+
- xdgbasedir module
To install the module you can use the installmodule.tcl script or if you want to manually copy the file AppDirs-*.tm
to a specific location that tcl expects to find modules. This would typically be something like:
/usr/share/tcltk/tcl8.6/tcl8/
To find out what directories are searched for modules, start tclsh
and enter:
foreach dir [split [::tcl::tm::path list]] {puts $dir}
or from the command line:
$ echo "foreach dir [split [::tcl::tm::path list]] {puts \$dir}" | tclsh
First create an instance of the AppDirs
class by instantiating it with a brand and applicationName. The brand may be ignored depending on the platform that is being used. You can then call the methods on this instance as follows:
package require AppDirs
set myAppDirs [AppDirs new myBrand myApp]
# Return location of user-specific data files
puts "data home: [$myAppDirs dataHome]"
# Return location of user-specific configuration files
puts "config home: [$myAppDirs configHome]"
# Return a list of locations for system-wide configuration files in preference order
puts "data dirs: [$myAppDirs dataDirs]"
# Return a list of locations for system-wide data files in preference order
puts "config dirs: [$myAppDirs configDirs]"
There is a testsuite in tests/
. To run it:
$ tclsh tests/appdirs.test.tcl
If you want to improve this module make a pull request to the repo on github. Please put any pull requests in a separate branch to ease integration and add a test to prove that it works.
Copyright (C) 2013, Lawrence Woodman [email protected]
This software is licensed under an MIT Licence. Please see the file, LICENCE.md, for details.