Compare commits
3
Commits
21bc239cef
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d061e74ea | ||
|
|
b95829bd05 | ||
|
|
2644932686 |
@@ -1,10 +1,11 @@
|
|||||||
use fmt;
|
use fmt;
|
||||||
use fs;
|
use fs;
|
||||||
use format::desktop_entry;
|
use format::xdg::ini;
|
||||||
use getopt;
|
use getopt;
|
||||||
use io;
|
use io;
|
||||||
use locale;
|
use locale;
|
||||||
use os;
|
use os;
|
||||||
|
use xdg::desktop_entry;
|
||||||
|
|
||||||
export fn main() void = {
|
export fn main() void = {
|
||||||
const name = os::args[0];
|
const name = os::args[0];
|
||||||
@@ -47,10 +48,10 @@ export fn main() void = {
|
|||||||
os::stderr, "{}: {}: {}\n",
|
os::stderr, "{}: {}: {}\n",
|
||||||
name, file_name, fs::strerror(err))!;
|
name, file_name, fs::strerror(err))!;
|
||||||
os::exit(os::status::FAILURE);
|
os::exit(os::status::FAILURE);
|
||||||
case let err: desktop_entry::error =>
|
case let err: ini::error =>
|
||||||
fmt::fprintf(
|
fmt::fprintf(
|
||||||
os::stderr, "{}: {}: {}\n",
|
os::stderr, "{}: {}: {}\n",
|
||||||
name, file_name, desktop_entry::strerror(err))!;
|
name, file_name, ini::strerror(err))!;
|
||||||
os::exit(os::status::FAILURE);
|
os::exit(os::status::FAILURE);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ export fn main() void = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
fn parse_file (file_name: str) (desktop_entry::file | fs::error | desktop_entry::error) = {
|
fn parse_file (file_name: str) (desktop_entry::file | fs::error | ini::error) = {
|
||||||
let file = os::open(file_name)?;
|
let file = os::open(file_name)?;
|
||||||
defer io::close(file)!;
|
defer io::close(file)!;
|
||||||
return desktop_entry::parse(file);
|
return desktop_entry::parse(file);
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
The basedir module implements the XDG Base Directory Specification as described
|
||||||
|
in (https://specifications.freedesktop.org/basedir-spec/latest/).
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
// Returns the single base directory relative to which user-specific data files
|
||||||
|
// should be written, which is defined by $XDG_DATA_HOME. If $XDG_DATA_HOME is
|
||||||
|
// either not set or empty, a default equal to $HOME/.local/share is used.
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.
|
||||||
|
export fn data_home (prog: str = "") str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns the single base directory relative to which user-specific
|
||||||
|
// configuration files should be written, which is defined by $XDG_CONFIG_HOME.
|
||||||
|
// If $XDG_CONFIG_HOME is either not set or empty, a default equal to
|
||||||
|
// $HOME/.config is used.
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.s
|
||||||
|
export fn config_home (prog: str = "") str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns the single base directory relative to which user-specific state data
|
||||||
|
// that should persist between (application) restarts, but that is not important
|
||||||
|
// or portable enough to the user that it should be stored. It is defined by
|
||||||
|
// $XDG_STATE_HOME. It may contain:
|
||||||
|
//
|
||||||
|
// - actions history (logs, history, recently used files, …)
|
||||||
|
// - current state of the application that can be reused on a restart (view,
|
||||||
|
// layout, open files, undo history, …)
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.
|
||||||
|
export fn state_home (prog: str = "") str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
// CacheHome returns the single base directory relative to which user-specific
|
||||||
|
// non-essential (cached) data should be written, which is defined by
|
||||||
|
// $XDG_CACHE_HOME. If $XDG_CACHE_HOME is either not set or empty, a default
|
||||||
|
// equal to $HOME/.cache is used.
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.
|
||||||
|
export fn cache_home (prog: str = "") str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns the single base directory relative to which user-specific runtime
|
||||||
|
// files and other file objects should be placed, which is defined by
|
||||||
|
// $XDG_RUNTIME_DIR. This module does not provide a fallback directory. If this
|
||||||
|
// function returns an error, applications should fall back to a replacement
|
||||||
|
// directory with similar capabilities (in accordance with §3) and print a
|
||||||
|
// warning message.
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.
|
||||||
|
export fn runtime_dir (prog: str = "") str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns the set of preference ordered base directories relative to which data
|
||||||
|
// files should be searched, which is defined by $XDG_DATA_DIRS. If
|
||||||
|
// $XDG_DATA_DIRS is either not set or empty, a value equal to
|
||||||
|
// /usr/local/share/:/usr/share/ is used. It is reccomended to call [[data_all]]
|
||||||
|
// instead for most use cases.
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.
|
||||||
|
export fn data_dirs (prog: str = "") []str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns set of preference ordered base directories relative to which
|
||||||
|
// configuration files should be searched, which is defined by $XDG_CONFIG_DIRS.
|
||||||
|
// If $XDG_CONFIG_DIRS is either not set or empty, a value equal to /etc/xdg is
|
||||||
|
// used. It is reccomended to call [[config_all]] instead for most use cases.
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.
|
||||||
|
export fn config_dirs (prog: str = "") []str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns the result of [[data_home]] in front of [[data_dirs]].
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.
|
||||||
|
export fn data_all (prog: str = "") []str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns the result of [[config_home]] in front of [[config_dirs]].
|
||||||
|
//
|
||||||
|
// The memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dup]] to extend its lifetime.
|
||||||
|
export fn config_all (prog: str = "") []str = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Returns the set of directories in which themes should be looked for in order
|
||||||
|
// of preference. It will return $HOME/.icons (for backwards compatibility),
|
||||||
|
// $XDG_DATA_DIRS/icons, and /usr/share/pixmaps. Applications may further add
|
||||||
|
// their own icon directories to this list.
|
||||||
|
//
|
||||||
|
// This memory is statically allocated and must not be free'd. It may be
|
||||||
|
// overwritten later, so use [[strings::dupall]] to extend its lifetime.
|
||||||
|
export fn theme_dirs() ([]str | error) = {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user