23 #include "libfmqtglobals.h" 36 Path(FmPath* path,
bool takeOwnership =
false): data_(path) {
37 if(path && !takeOwnership)
41 Path(
const Path& other): data_(other.data_ ? fm_path_ref(other.data_) : NULL) {
44 Path(GFile* gf): data_(fm_path_new_for_gfile(gf)) {
52 static Path fromPathName(
const char* path_name) {
53 return Path(fm_path_new_for_path(path_name),
true);
56 static Path fromUri(
const char* uri) {
57 return Path(fm_path_new_for_uri(uri),
true);
60 static Path fromDisplayName(
const char* path_name) {
61 return Path(fm_path_new_for_display_name(path_name),
true);
64 static Path fromString(
const char* path_str) {
65 return Path(fm_path_new_for_str(path_str),
true);
68 static Path fromCommandlineArg(
const char* arg) {
69 return Path(fm_path_new_for_commandline_arg(arg),
true);
72 Path child(
const char* basename) {
73 return Path(fm_path_new_child(data_, basename),
true);
76 Path child(
const char* basename,
int name_len) {
77 return Path(fm_path_new_child_len(data_, basename, name_len),
true);
80 Path relative(
const char* rel) {
81 return Path(fm_path_new_relative(data_, rel),
true);
85 static Path root(
void) {
86 return Path(fm_path_get_root(),
false);
89 static Path home(
void) {
90 return Path(fm_path_get_home(),
false);
93 static Path desktop(
void) {
94 return Path(fm_path_get_desktop(),
false);
97 static Path trash(
void) {
98 return Path(fm_path_get_trash(),
false);
101 static Path appsMenu(
void) {
102 return Path(fm_path_get_apps_menu(),
false);
106 return Path(fm_path_get_parent(data_),
false);
109 const char* basename() {
110 return fm_path_get_basename(data_);
113 FmPathFlags flags() {
114 return fm_path_get_flags(data_);
117 bool hasPrefix(FmPath* prefix) {
118 return fm_path_has_prefix(data_, prefix);
122 return Path(fm_path_get_scheme_path(data_),
true);
126 return fm_path_is_native(data_);
130 return fm_path_is_trash(data_);
134 return fm_path_is_trash_root(data_);
137 bool isNativeOrTrash() {
138 return fm_path_is_native_or_trash(data_);
142 return fm_path_to_str(data_);
145 QByteArray toByteArray() {
146 char* s = fm_path_to_str(data_);
153 return fm_path_to_uri(data_);
157 return fm_path_to_gfile(data_);
166 QString displayName(
bool human_readable =
true) {
167 char* dispname = fm_path_display_name(data_, human_readable);
168 QString str = QString::fromUtf8(dispname);
179 QString displayBasename() {
180 char* basename = fm_path_display_basename(data_);
181 QString s = QString::fromUtf8(basename);
188 return fm_path_hash(data_);
191 void take(FmPath* path) {
193 fm_path_unref(data_);
197 Path& operator = (
const Path& other) {
199 fm_path_unref(data_);
200 data_ = fm_path_ref(other.data_);
204 bool operator == (
const Path& other)
const {
205 return fm_path_equal(data_, other.data_);
208 bool operator != (
const Path& other)
const {
209 return !fm_path_equal(data_, other.data_);
212 bool operator < (
const Path& other)
const {
213 return compare(other);
216 bool operator > (
const Path& other)
const {
217 return (other < *
this);
221 int compare(
const Path& other)
const {
222 return fm_path_compare(data_, other.data_);
226 bool equal(
const gchar *str,
int n)
const {
227 return fm_path_equal_str(data_, str, n);
232 return fm_path_depth(data_);
235 FmPath* data()
const {
245 Q_DECLARE_OPAQUE_POINTER(FmPath*)
Definition: appchoosercombobox.cpp:26