allegro_sys/
path.rs

1// Copyright (c) 2014 by SiegeLord
2//
3// All rights reserved. Distributed under ZLib. For full terms see the file LICENSE.
4
5use allegro_util::c_bool;
6use libc::*;
7
8#[cfg(windows)]
9pub const ALLEGRO_NATIVE_PATH_SEP: char = '\\';
10#[cfg(windows)]
11pub const ALLEGRO_NATIVE_DRIVE_SEP: char = ':';
12
13#[cfg(not(windows))]
14pub const ALLEGRO_NATIVE_PATH_SEP: char = '/';
15#[cfg(not(windows))]
16pub const ALLEGRO_NATIVE_DRIVE_SEP: char = '\x00';
17
18allegro_util::opaque!(ALLEGRO_PATH);
19
20unsafe extern "C" {
21	pub fn al_create_path(str: *const c_char) -> *mut ALLEGRO_PATH;
22	pub fn al_create_path_for_directory(str: *const c_char) -> *mut ALLEGRO_PATH;
23	pub fn al_clone_path(path: *const ALLEGRO_PATH) -> *mut ALLEGRO_PATH;
24
25	pub fn al_get_path_num_components(path: *const ALLEGRO_PATH) -> c_int;
26	pub fn al_get_path_component(path: *const ALLEGRO_PATH, i: c_int) -> *const c_char;
27	pub fn al_replace_path_component(path: *mut ALLEGRO_PATH, i: c_int, s: *const c_char);
28	pub fn al_remove_path_component(path: *mut ALLEGRO_PATH, i: c_int);
29	pub fn al_insert_path_component(path: *mut ALLEGRO_PATH, i: c_int, s: *const c_char);
30	pub fn al_get_path_tail(path: *const ALLEGRO_PATH) -> *const c_char;
31	pub fn al_drop_path_tail(path: *mut ALLEGRO_PATH);
32	pub fn al_append_path_component(path: *mut ALLEGRO_PATH, s: *const c_char);
33	pub fn al_join_paths(path: *const ALLEGRO_PATH, tail: *const ALLEGRO_PATH) -> c_bool;
34	pub fn al_rebase_path(head: *const ALLEGRO_PATH, tail: *const ALLEGRO_PATH) -> c_bool;
35	pub fn al_path_cstr(path: *const ALLEGRO_PATH, delim: c_char) -> *const c_char;
36	pub fn al_destroy_path(path: *const ALLEGRO_PATH);
37
38	pub fn al_set_path_drive(path: *mut ALLEGRO_PATH, drive: *const c_char);
39	pub fn al_get_path_drive(path: *const ALLEGRO_PATH) -> *const c_char;
40
41	pub fn al_set_path_filename(path: *mut ALLEGRO_PATH, filename: *const c_char);
42	pub fn al_get_path_filename(path: *const ALLEGRO_PATH) -> *const c_char;
43
44	pub fn al_get_path_extension(path: *const ALLEGRO_PATH) -> *const c_char;
45	pub fn al_set_path_extension(path: *mut ALLEGRO_PATH, extension: *const c_char) -> c_bool;
46	pub fn al_get_path_basename(path: *const ALLEGRO_PATH) -> *const c_char;
47
48	pub fn al_make_path_canonical(path: *mut ALLEGRO_PATH) -> c_bool;
49}