/usr/include/libfm-qt/path.h is in libfm-qt-dev 0.10.0+20151214-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | /*
* Copyright (C) 2013 - 2015 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef FM_PATH_H
#define FM_PATH_H
#include "libfmqtglobals.h"
#include <libfm/fm.h>
#include <QString>
#include <QMetaType>
namespace Fm {
class LIBFM_QT_API Path {
public:
Path(): data_(nullptr) {
}
Path(FmPath* path, bool takeOwnership = false): data_(path) {
if(path && !takeOwnership)
fm_path_ref(data_);
}
Path(const Path& other): data_(other.data_ ? fm_path_ref(other.data_) : nullptr) {
}
Path(GFile* gf): data_(fm_path_new_for_gfile(gf)) {
}
~Path() {
if(data_)
fm_path_unref(data_);
}
static Path fromPathName(const char* path_name) {
return Path(fm_path_new_for_path(path_name), true);
}
static Path fromUri(const char* uri) {
return Path(fm_path_new_for_uri(uri), true);
}
static Path fromDisplayName(const char* path_name) {
return Path(fm_path_new_for_display_name(path_name), true);
}
static Path fromString(const char* path_str) {
return Path(fm_path_new_for_str(path_str), true);
}
static Path fromCommandlineArg(const char* arg) {
return Path(fm_path_new_for_commandline_arg(arg), true);
}
Path child(const char* basename) {
return Path(fm_path_new_child(data_, basename), true);
}
Path child(const char* basename, int name_len) {
return Path(fm_path_new_child_len(data_, basename, name_len), true);
}
Path relative(const char* rel) {
return Path(fm_path_new_relative(data_, rel), true);
}
/* predefined paths */
static Path root(void) { /* / */
return Path(fm_path_get_root(), false);
}
static Path home(void) { /* home directory */
return Path(fm_path_get_home(), false);
}
static Path desktop(void) { /* $HOME/Desktop */
return Path(fm_path_get_desktop(), false);
}
static Path trash(void) { /* trash:/// */
return Path(fm_path_get_trash(), false);
}
static Path appsMenu(void) { /* menu://applications.menu/ */
return Path(fm_path_get_apps_menu(), false);
}
Path parent() {
return Path(data_ != nullptr ? fm_path_get_parent(data_) : nullptr, false);
}
const char* basename() {
return fm_path_get_basename(data_);
}
FmPathFlags flags() {
return fm_path_get_flags(data_);
}
bool hasPrefix(FmPath* prefix) {
return fm_path_has_prefix(data_, prefix);
}
Path schemePath() {
return Path(fm_path_get_scheme_path(data_), true);
}
bool isNative() {
return fm_path_is_native(data_);
}
bool isTrash() {
return fm_path_is_trash(data_);
}
bool isTrashRoot() {
return fm_path_is_trash_root(data_);
}
bool isNativeOrTrash() {
return fm_path_is_native_or_trash(data_);
}
char* toString() {
return fm_path_to_str(data_);
}
QByteArray toByteArray() {
char* s = fm_path_to_str(data_);
QByteArray str(s);
g_free(s);
return str;
}
char* toUri() {
return fm_path_to_uri(data_);
}
GFile* toGfile() {
return fm_path_to_gfile(data_);
}
/*
char* displayName(bool human_readable = true) {
return fm_path_display_name(data_, human_readable);
}
*/
QString displayName(bool human_readable = true) {
char* dispname = fm_path_display_name(data_, human_readable);
QString str = QString::fromUtf8(dispname);
g_free(dispname);
return str;
}
/*
char* displayBasename() {
return fm_path_display_basename(data_);
}
*/
QString displayBasename() {
char* basename = fm_path_display_basename(data_);
QString s = QString::fromUtf8(basename);
g_free(basename);
return s;
}
/* For used in hash tables */
guint hash() {
return fm_path_hash(data_);
}
void take(FmPath* path) { // take the ownership of the "path"
if(data_)
fm_path_unref(data_);
data_ = path;
}
Path& operator = (const Path& other) {
if(data_)
fm_path_unref(data_);
data_ = fm_path_ref(other.data_);
return *this;
}
bool operator == (const Path& other) const {
return fm_path_equal(data_, other.data_);
}
bool operator != (const Path& other) const {
return !fm_path_equal(data_, other.data_);
}
bool operator < (const Path& other) const {
return compare(other);
}
bool operator > (const Path& other) const {
return (other < *this);
}
/* can be used for sorting */
int compare(const Path& other) const {
return fm_path_compare(data_, other.data_);
}
/* used for completion in entry */
bool equal(const gchar *str, int n) const {
return fm_path_equal_str(data_, str, n);
}
/* calculate how many elements are in this path. */
int depth() const {
return fm_path_depth(data_);
}
FmPath* data() const {
return data_;
}
private:
FmPath* data_;
};
}
Q_DECLARE_OPAQUE_POINTER(FmPath*)
#endif // FM_PATH_H
|