basedir(PathType, Application, Opts) -> file:filename_all()
OTP 19.0basedir(PathsType, Application, Opts) -> [file:filename_all()]
OTP 19.0
類型:
PathType = basedir_path_type()
PathsType = basedir_paths_type()
Application = string() | binary()
Opts = basedir_opts()
basedir_path_type() =
user_cache | user_config | user_data | user_log
user_cache | user_config | user_data | user_log
basedir_paths_type() = site_config | site_data
返回給定類型的一個或多個合適的路徑。如果Opts
中未設置os
,則該函數將默認為本機選項,即'linux'
、'darwin'
或'windows'
,如os:type/0
所理解的那樣。任何未識別為 'darwin'
或 'windows'
的內容都會被解釋為 'linux'
。
選項'author'
和'version'
僅與'windows'
選項模式一起使用。
-
user_cache
該路徑位置適用於本地計算機上的臨時數據文件。
在 Linux 上:尊重操作係統環境變量
XDG_CACHE_HOME
。1> filename:basedir(user_cache, "my_application", #{os=>linux}). "/home/otptest/.cache/my_application"
1> filename:basedir(user_cache, "my_application", #{os=>darwin}). "/home/otptest/Library/Caches/my_application"
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"
-
user_config
該路徑位置用於持久配置文件。
在 Linux 上:尊重操作係統環境變量
XDG_CONFIG_HOME
。2> filename:basedir(user_config, "my_application", #{os=>linux}). "/home/otptest/.config/my_application"
2> filename:basedir(user_config, "my_application", #{os=>darwin}). "/home/otptest/Library/Application Support/my_application"
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"
-
user_data
該路徑位置用於持久數據文件。
在 Linux 上:尊重操作係統環境變量
XDG_DATA_HOME
。3> filename:basedir(user_data, "my_application", #{os=>linux}). "/home/otptest/.local/my_application"
3> filename:basedir(user_data, "my_application", #{os=>darwin}). "/home/otptest/Library/Application Support/my_application"
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"
-
user_log
該路徑位置適用於本地計算機上的臨時日誌文件。
在 Linux 上:尊重操作係統環境變量
XDG_CACHE_HOME
。4> filename:basedir(user_log, "my_application", #{os=>linux}). "/home/otptest/.cache/my_application/log"
4> filename:basedir(user_log, "my_application", #{os=>darwin}). "/home/otptest/Library/Logs/my_application"
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"
-
site_config
在 Linux 上:尊重操作係統環境變量
XDG_CONFIG_DIRS
。5> filename:basedir(site_config, "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"]
5> filename:basedir(site_config, "my_application", #{os=>darwin}). ["/Library/Application Support/my_application"]
-
site_data
在 Linux 上:尊重操作係統環境變量
XDG_DATA_DIRS
。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"]
5> filename:basedir(site_data, "my_application", #{os=>darwin}). ["/Library/Application Support/my_application"]
相關用法
- erlang basename(Filename)用法及代碼示例
- erlang basename(Filename, Ext)用法及代碼示例
- erlang binary_to_atom用法及代碼示例
- erlang byte_size用法及代碼示例
- erlang binary_part用法及代碼示例
- erlang binary_to_float用法及代碼示例
- erlang binary_to_integer用法及代碼示例
- erlang binary_to_list用法及代碼示例
- erlang binary_part(Subject, PosLen)用法及代碼示例
- erlang binary_to_atom(Binary, Encoding)用法及代碼示例
- erlang binary_to_float(Binary)用法及代碼示例
- erlang binary_to_integer(Binary)用法及代碼示例
- erlang binary_to_integer(Binary, Base)用法及代碼示例
- erlang binary_to_term(Binary)用法及代碼示例
- erlang binary_to_term(Binary, Opts)用法及代碼示例
- erlang bit_size(Bitstring)用法及代碼示例
- erlang bitstring_to_list(Bitstring)用法及代碼示例
- erlang byte_size(Bitstring)用法及代碼示例
- erlang bin_to_list(Subject, PosLen)用法及代碼示例
- erlang sin用法及代碼示例
- erlang cos用法及代碼示例
- erlang tan用法及代碼示例
- erlang asin用法及代碼示例
- erlang acos用法及代碼示例
- erlang atan用法及代碼示例
注:本文由純淨天空篩選整理自erlang.org大神的英文原創作品 basedir(PathType, Application, Opts) -> file:filename_all()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。