Class: Wx::StandardPaths
- Inherits:
-
Object
- Object
- Wx::StandardPaths
- Defined in:
- lib/wx/doc/gen/app_traits.rb
Overview
This class is untracked and should not be derived from nor instances extended!
StandardPaths returns the standard locations in the file system and should be used by applications to find their data files in a portable way.
Note that you must not create objects of class StandardPaths directly, but use the global standard paths object returned by StandardPaths.get (which can be of a type derived from StandardPaths and not of exactly this type) and call the methods you need on it. The object returned by StandardPaths.get may be customized by overriding AppTraits#get_standard_paths methods. In the description of the methods below, the example return values are given for the Unix, Windows and macOS systems, however please note that these are just the examples and the actual values may differ. For example, under Windows: the system administrator may change the standard directories locations, e.g. the Windows directory may be named "W:\Win2003"
instead of the default "C:\Windows"
. Notice that in the examples below the string appinfo may be either just the application name (as returned by App#get_app_name) or a combination of the vendor name (App#get_vendor_name) and the application name, with a path separator between them. By default, only the application name is used, use #use_app_info to change this. The other placeholders should be self-explanatory: the string username should be replaced with the value the name of the currently logged in user. and prefix is only used under Unix and is /usr/local
by default but may be changed using #set_install_prefix. The directories returned by the methods of this class may or may not exist. If they don’t exist, it’s up to the caller to create them, StandardPaths doesn’t do it. Finally note that these functions only work with standardly packaged applications. I.e. under Unix you should follow the standard installation conventions and under Mac you should create your application bundle according to the Apple guidelines. Again, this class doesn’t help you to do it. This class is MT-safe: its methods may be called concurrently from different threads without additional locking.
Category: File Handling
Defined Under Namespace
Classes: ConfigFileConv, Dir, FileLayout, ResourceCat
Class Method Summary collapse
-
.get ⇒ Wx::StandardPaths
Returns reference to the unique global standard paths object.
-
.msw_get_shell_dir(csidl) ⇒ String
Returns location of Windows shell special folder.
Instance Method Summary collapse
-
#dont_ignore_app_sub_dir ⇒ void
MSW-specific function undoing the effect of #ignore_app_sub_dir calls.
-
#get_app_documents_dir ⇒ String
(also: #app_documents_dir)
Return the directory for the document files used by this application.
-
#get_config_dir ⇒ String
(also: #config_dir)
Return the directory containing the system config files.
-
#get_data_dir ⇒ String
(also: #data_dir)
Return the location of the applications global, i.e.
-
#get_documents_dir ⇒ String
(also: #documents_dir)
Same as calling #get_user_dir with Dir_Documents parameter.
-
#get_executable_path ⇒ String
(also: #executable_path)
Return the directory and the filename for the current executable.
-
#get_file_layout ⇒ Wx::StandardPaths::FileLayout
(also: #file_layout)
Returns the current file layout.
-
#get_install_prefix ⇒ String
(also: #install_prefix)
Return the program installation prefix, e.g.
-
#get_local_data_dir ⇒ String
(also: #local_data_dir)
Return the location for application data files which are host-specific and can’t, or shouldn’t, be shared with the other machines.
-
#get_localized_resources_dir(lang, category = RESOURCE_CAT_NONE) ⇒ String
(also: #localized_resources_dir)
Return the localized resources directory containing the resource files of the specified category for the given language.
-
#get_plugins_dir ⇒ String
(also: #plugins_dir)
Return the directory where the loadable modules (plugins) live.
-
#get_resources_dir ⇒ String
(also: #resources_dir)
Return the directory where the application resource files are located.
-
#get_temp_dir ⇒ String
(also: #temp_dir)
Return the directory for storing temporary files, for the current user.
-
#get_user_config_dir ⇒ String
(also: #user_config_dir)
Return the directory for the user config files.
-
#get_user_data_dir ⇒ String
(also: #user_data_dir)
Return the directory for the user-dependent application data files:.
-
#get_user_dir(userDir) ⇒ String
(also: #user_dir)
Return the path of the specified user data directory.
-
#get_user_local_data_dir ⇒ String
(also: #user_local_data_dir)
Return the directory for user data files which shouldn’t be shared with the other machines.
-
#ignore_app_build_sub_dirs ⇒ void
MSW-specific function to ignore all common build directories.
-
#ignore_app_sub_dir(subdirPattern) ⇒ void
MSW-specific function to customize application directory detection.
-
#make_config_file_name(basename, conv = CONFIG_FILE_CONV_EXT) ⇒ String
Return the file name which would be used by FileConfig if it were constructed with basename.
-
#set_file_layout(layout) ⇒ void
(also: #file_layout=)
Sets the current file layout.
-
#set_install_prefix(prefix) ⇒ void
(also: #install_prefix=)
Lets StandardPaths know about the real program installation prefix on a Unix system.
-
#use_app_info(info) ⇒ void
Controls what application information is used when constructing paths that should be unique to this program, such as the application data directory, the plugins directory on Unix, etc.
Class Method Details
.get ⇒ Wx::StandardPaths
Returns reference to the unique global standard paths object.
393 |
# File 'lib/wx/doc/gen/app_traits.rb', line 393 def self.get; end |
.msw_get_shell_dir(csidl) ⇒ String
Returns location of Windows shell special folder.
This function is, by definition, MSW-specific. It can be used to access pre-defined shell directories not covered by the existing methods of this class, e.g.:
\#ifdef __WXMSW__
// get the location of files waiting to be burned on a CD
wxString cdburnArea =
wxStandardPaths::MSWGetShellDir(CSIDL_CDBURN_AREA);
\#endif // __WXMSW__
408 |
# File 'lib/wx/doc/gen/app_traits.rb', line 408 def self.msw_get_shell_dir(csidl) end |
Instance Method Details
#dont_ignore_app_sub_dir ⇒ void
This method returns an undefined value.
MSW-specific function undoing the effect of #ignore_app_sub_dir calls.
After a call to this function the program directory will be exactly the directory containing the main application binary, i.e. it undoes the effect of any previous #ignore_app_sub_dir calls including the ones done indirectly by #ignore_app_build_sub_dirs called from the class constructor.
141 |
# File 'lib/wx/doc/gen/app_traits.rb', line 141 def dont_ignore_app_sub_dir; end |
#get_app_documents_dir ⇒ String Also known as: app_documents_dir
Return the directory for the document files used by this application.
If the application-specific directory doesn’t exist, this function returns #get_documents_dir. Example return values:
-
Unix:
~/appinfo
-
Windows:
"C:\Users\username\Documents\appinfo"
or"C:\Documents and Settings\username\My Documents\appinfo"
-
Mac:
~/Documents/appinfo
152 |
# File 'lib/wx/doc/gen/app_traits.rb', line 152 def get_app_documents_dir; end |
#get_config_dir ⇒ String Also known as: config_dir
Return the directory containing the system config files.
Example return values:
-
Unix:
/etc
-
Windows:
"C:\ProgramData\appinfo"
or"C:\Documents and Settings\All Users\Application Data\appinfo"
-
Mac:
/Library/Preferences
Under Windows this includes appinfo which makes it inconsistent with other ports.
170 |
# File 'lib/wx/doc/gen/app_traits.rb', line 170 def get_config_dir; end |
#get_data_dir ⇒ String Also known as: data_dir
Return the location of the applications global, i.e. not user-specific, data files.
Example return values:
-
Unix:
prefix/share/appinfo
-
Windows: the directory where the executable file is located
-
Mac:
appinfo.app/Contents/SharedSupport
bundle subdirectory
Under Unix (only) it is possible to override the default value returned from this function by setting the value of WX_APPNAME_DATA_DIR environment variable to the directory to use (where APPNAME is the upper-cased value of App#get_app_name). This is useful in order to be able to run applications using this function without installing them as you can simply set this environment variable to the source directory location to allow the application to find its files there.
184 |
# File 'lib/wx/doc/gen/app_traits.rb', line 184 def get_data_dir; end |
#get_documents_dir ⇒ String Also known as: documents_dir
Same as calling #get_user_dir with Dir_Documents parameter.
193 |
# File 'lib/wx/doc/gen/app_traits.rb', line 193 def get_documents_dir; end |
#get_executable_path ⇒ String Also known as: executable_path
Return the directory and the filename for the current executable.
Example return values:
-
Unix:
/usr/local/bin/exename
-
Windows:
"C:\Programs\AppFolder\exename.exe"
-
Mac:
/Applications/exename
.app/Contents/MacOS/exename
204 |
# File 'lib/wx/doc/gen/app_traits.rb', line 204 def get_executable_path; end |
#get_file_layout ⇒ Wx::StandardPaths::FileLayout Also known as: file_layout
Returns the current file layout.
380 |
# File 'lib/wx/doc/gen/app_traits.rb', line 380 def get_file_layout; end |
#get_install_prefix ⇒ String Also known as: install_prefix
Return the program installation prefix, e.g. /usr
, /opt
or /home/zeitlin
.
If the prefix had been previously by #set_install_prefix, returns that value, otherwise tries to determine it automatically (Linux only right now) and finally returns the default /usr/local
value if it failed.
This function is only available under Unix platforms (but not limited to WXGTK mentioned below).
Availability: only available for the WXGTK port.
220 |
# File 'lib/wx/doc/gen/app_traits.rb', line 220 def get_install_prefix; end |
#get_local_data_dir ⇒ String Also known as: local_data_dir
Return the location for application data files which are host-specific and can’t, or shouldn’t, be shared with the other machines.
This is the same as #get_data_dir except under Unix where it returns /etc/appinfo
.
227 |
# File 'lib/wx/doc/gen/app_traits.rb', line 227 def get_local_data_dir; end |
#get_localized_resources_dir(lang, category = RESOURCE_CAT_NONE) ⇒ String Also known as: localized_resources_dir
Return the localized resources directory containing the resource files of the specified category for the given language.
In general this is just the same as lang subdirectory of #get_resources_dir (or lang.lproj under macOS) but is something quite different for message catalog category under Unix where it returns the standard prefix/share/locale/lang/LC_MESSAGES
directory.
236 |
# File 'lib/wx/doc/gen/app_traits.rb', line 236 def get_localized_resources_dir(lang, category=RESOURCE_CAT_NONE) end |
#get_plugins_dir ⇒ String Also known as: plugins_dir
Return the directory where the loadable modules (plugins) live.
Example return values:
-
Unix:
prefix/lib/appinfo
-
Windows: the directory of the executable file
-
Mac:
appinfo.app/Contents/PlugIns
bundle subdirectory
248 |
# File 'lib/wx/doc/gen/app_traits.rb', line 248 def get_plugins_dir; end |
#get_resources_dir ⇒ String Also known as: resources_dir
Return the directory where the application resource files are located.
The resources are the auxiliary data files needed for the application to run and include, for example, image and sound files it might use. This function is the same as #get_data_dir for all platforms except macOS. Example return values:
-
Unix:
prefix/share/appinfo
-
Windows: the directory where the executable file is located
-
Mac:
appinfo.app/Contents/Resources
bundle subdirectory
261 |
# File 'lib/wx/doc/gen/app_traits.rb', line 261 def get_resources_dir; end |
#get_temp_dir ⇒ String Also known as: temp_dir
Return the directory for storing temporary files, for the current user.
Same as Wx::FileName#get_temp_dir. To create unique temporary files, it is best to use Wx::FileName#create_temp_file_name for correct behaviour when multiple processes are attempting to create temporary files.
268 |
# File 'lib/wx/doc/gen/app_traits.rb', line 268 def get_temp_dir; end |
#get_user_config_dir ⇒ String Also known as: user_config_dir
Return the directory for the user config files.
This directory is:
-
Unix:
~
(the home directory) or XDG_CONFIG_HOME depending on #get_file_layout return value -
Windows:
"C:\Users\username\AppData\Roaming"
or"C:\Documents and Settings\username\Application Data"
-
Mac:
~/Library/Preferences
Only use this method if you have a single configuration file to put in this directory, otherwise #get_user_data_dir is more appropriate as the latter adds appinfo to the path, unlike this function.
281 |
# File 'lib/wx/doc/gen/app_traits.rb', line 281 def get_user_config_dir; end |
#get_user_data_dir ⇒ String Also known as: user_data_dir
Return the directory for the user-dependent application data files:
-
Unix:
~/
.appinfo -
Windows:
"C:\Users\username\AppData\Roaming\appinfo"
or"C:\Documents and Settings\username\Application Data\appinfo"
-
Mac:
"~/Library/Application Support/appinfo"
290 |
# File 'lib/wx/doc/gen/app_traits.rb', line 290 def get_user_data_dir; end |
#get_user_dir(userDir) ⇒ String Also known as: user_dir
Return the path of the specified user data directory.
If the value could not be determined the users home directory is returned.
On Unix this (newer) method always respects the XDG base directory specification, even if #set_file_layout with FileLayout_XDG hadn't been called.
304 |
# File 'lib/wx/doc/gen/app_traits.rb', line 304 def get_user_dir(userDir) end |
#get_user_local_data_dir ⇒ String Also known as: user_local_data_dir
Return the directory for user data files which shouldn’t be shared with the other machines.
This is the same as #get_user_data_dir for all platforms except Windows where it returns "C:\Users\username\AppData\Local\appinfo"
or "C:\Documents and Settings\username\Local Settings\Application Data\appinfo"
311 |
# File 'lib/wx/doc/gen/app_traits.rb', line 311 def get_user_local_data_dir; end |
#ignore_app_build_sub_dirs ⇒ void
This method returns an undefined value.
MSW-specific function to ignore all common build directories.
This function calls #ignore_app_sub_dir with all common values for build directory, e.g. "debug"
and "release"
. It is called by the class constructor and so the build directories are always ignored by default. You may use #dont_ignore_app_sub_dir to avoid ignoring them if this is inappropriate for your application.
334 |
# File 'lib/wx/doc/gen/app_traits.rb', line 334 def ignore_app_build_sub_dirs; end |
#ignore_app_sub_dir(subdirPattern) ⇒ void
This method returns an undefined value.
MSW-specific function to customize application directory detection.
This class supposes that data, plugins &c files are located under the program directory which is the directory containing the application binary itself. But sometimes this binary may be in a subdirectory of the main program directory, e.g. this happens in at least the following common cases:
-
The program is in “bin” subdirectory of the installation directory.
-
The program is in “debug” subdirectory of the directory containing sources and data files during development
By calling this function you instruct the class to remove the last component of the path if it matches its argument. Notice that it may be called more than once, e.g. you can call both IgnoreAppSubDir(“bin”) and IgnoreAppSubDir(“debug”) to take care of both production and development cases above but that each call will only remove the last path component. Finally note that the argument can contain wild cards so you can also call IgnoreAppSubDir(“vc_msw_”) to ignore all build directories at once when using wxWidgets-inspired output directories names.
326 |
# File 'lib/wx/doc/gen/app_traits.rb', line 326 def ignore_app_sub_dir(subdirPattern) end |
#make_config_file_name(basename, conv = CONFIG_FILE_CONV_EXT) ⇒ String
Return the file name which would be used by FileConfig if it were constructed with basename.
conv is used to construct the name of the file under Unix and only matters when using the class file layout, i.e. if #set_file_layout had not been called with FileLayout_XDG argument. In this case, this argument is used to determine whether to use an extension or a leading dot. When following XDG specification, the function always appends the extension, regardless of conv value. Finally, this argument is not used at all under non-Unix platforms.
389 |
# File 'lib/wx/doc/gen/app_traits.rb', line 389 def make_config_file_name(basename, conv=CONFIG_FILE_CONV_EXT) end |
#set_file_layout(layout) ⇒ void Also known as: file_layout=
This method returns an undefined value.
Sets the current file layout.
The default layout is FileLayout_Classic for compatibility, however newer applications are encouraged to set it to FileLayout_XDG on program startup.
372 |
# File 'lib/wx/doc/gen/app_traits.rb', line 372 def set_file_layout(layout) end |
#set_install_prefix(prefix) ⇒ void Also known as: install_prefix=
This method returns an undefined value.
Lets Wx::StandardPaths know about the real program installation prefix on a Unix system.
By default, the value returned by #get_install_prefix is used. Although under Linux systems the program prefix may usually be determined automatically, portable programs should call this function. Usually the prefix is set during program configuration if using GNU autotools and so it is enough to pass its value defined in config.h to this function.
This function is only available under Unix platforms (but not limited to WXGTK mentioned below).
Availability: only available for the WXGTK port.
351 |
# File 'lib/wx/doc/gen/app_traits.rb', line 351 def set_install_prefix(prefix) end |
#use_app_info(info) ⇒ void
This method returns an undefined value.
Controls what application information is used when constructing paths that should be unique to this program, such as the application data directory, the plugins directory on Unix, etc.
Valid values for info are:
-
AppInfo_None: use neither application nor vendor name in the paths.
-
AppInfo_AppName: use the application name in the paths.
-
AppInfo_VendorName: use the vendor name in the paths, usually used combined with AppInfo_AppName, i.e. as
AppInfo_AppName | AppInfo_VendorName
.
By default, only the application name is used.
365 |
# File 'lib/wx/doc/gen/app_traits.rb', line 365 def use_app_info(info) end |