From 6a8efbde7620e3fc6fffe354cb01edee5d13fc93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= The module supports raw file names in the way that if a binary is present, or the file name cannot be interpreted according to the return value of
+ Equivalent to
+ Returns a suitable path, or paths, for a given type.
+ If
+ The options
The path location is intended for transient data files on a local machine.
+
+ On Linux:
+ Respects the os environment variable
+1> filename:basedir(user_cache, "my_application", #{os=>linux}). +"/home/otptest/.cache/my_application"+ On Darwin:
+1> filename:basedir(user_cache, "my_application", #{os=>darwin}). +"/home/otptest/Library/Caches/my_application"+ On Windows:
+1> filename:basedir(user_cache, "My App"). +"c:/Users/otptest/AppData/Local/My App/Cache" +2> filename:basedir(user_cache, "My App"). +"c:/Users/otptest/AppData/Local/My App/Cache" +3> filename:basedir(user_cache, "My App", #{author=>"Erlang"}). +"c:/Users/otptest/AppData/Local/Erlang/My App/Cache" +4> filename:basedir(user_cache, "My App", #{version=>"1.2"}). +"c:/Users/otptest/AppData/Local/My App/1.2/Cache" +5> filename:basedir(user_cache, "My App", #{author=>"Erlang",version=>"1.2"}). +"c:/Users/otptest/AppData/Local/Erlang/My App/1.2/Cache"+
+ The path location is intended for persistent configuration files. +
+
+ On Linux:
+ Respects the os environment variable
+2> filename:basedir(user_config, "my_application", #{os=>linux}). +"/home/otptest/.config/my_application"+ On Darwin:
+2> filename:basedir(user_config, "my_application", #{os=>darwin}). +"/home/otptest/Library/Application Support/my_application"+ On Windows:
+1> filename:basedir(user_config, "My App"). +"c:/Users/otptest/AppData/Roaming/My App" +2> filename:basedir(user_config, "My App", #{author=>"Erlang", version=>"1.2"}). +"c:/Users/otptest/AppData/Roaming/Erlang/My App/1.2"+
+ The path location is intended for persistent data files. +
+
+ On Linux:
+ Respects the os environment variable
+3> filename:basedir(user_data, "my_application", #{os=>linux}). +"/home/otptest/.local/my_application"+ On Darwin:
+3> filename:basedir(user_data, "my_application", #{os=>darwin}). +"/home/otptest/Library/Application Support/my_application"+ On Windows:
+8> filename:basedir(user_data, "My App"). +"c:/Users/otptest/AppData/Local/My App" +9> filename:basedir(user_data, "My App",#{author=>"Erlang",version=>"1.2"}). +"c:/Users/otptest/AppData/Local/Erlang/My App/1.2"+
The path location is intended for transient log files on a local machine.
+
+ On Linux:
+ Respects the os environment variable
+4> filename:basedir(user_log, "my_application", #{os=>linux}). +"/home/otptest/.cache/my_application/log"+ On Darwin:
+4> filename:basedir(user_log, "my_application", #{os=>darwin}). +"/home/otptest/Library/Caches/my_application"+ On Windows:
+12> filename:basedir(user_log, "My App"). +"c:/Users/otptest/AppData/Local/My App/Logs" +13> filename:basedir(user_log, "My App",#{author=>"Erlang",version=>"1.2"}). +"c:/Users/otptest/AppData/Local/Erlang/My App/1.2/Logs"+
+ On Linux:
+ Respects the os environment variable
+5> filename:basedir(site_data, "my_application", #{os=>linux}). +["/usr/local/share/my_application", + "/usr/share/my_application"] +6> os:getenv("XDG_CONFIG_DIRS"). +"/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg" +7> filename:basedir(site_config, "my_application", #{os=>linux}). +["/etc/xdg/xdg-ubuntu/my_application", + "/usr/share/upstart/xdg/my_application", + "/etc/xdg/my_application"] +8> os:unsetenv("XDG_CONFIG_DIRS"). +true +9> filename:basedir(site_config, "my_application", #{os=>linux}). +["/etc/xdg/my_application"]+ On Darwin:
+5> filename:basedir(site_config, "my_application", #{os=>darwin}). +["/Library/Application Support/my_application"]+
+ On Linux:
+ Respects the os environment variable
+10> os:getenv("XDG_DATA_DIRS"). +"/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/" +11> filename:basedir(site_data, "my_application", #{os=>linux}). +["/usr/share/ubuntu/my_application", + "/usr/share/gnome/my_application", + "/usr/local/share/my_application", + "/usr/share/my_application"] +12> os:unsetenv("XDG_DATA_DIRS"). +true +13> filename:basedir(site_data, "my_application", #{os=>linux}). +["/usr/local/share/my_application", + "/usr/share/my_application"]+ On Darwin:
+5> filename:basedir(site_data, "my_application", #{os=>darwin}). +["/Library/Application Support/my_application"]+