Changeset View
Changeset View
Standalone View
Standalone View
krusader/FileSystem/filesystemprovider.cpp
Show All 35 Lines | |||||
36 | 36 | | |||
37 | #include "defaultfilesystem.h" | 37 | #include "defaultfilesystem.h" | ||
38 | #include "fileitem.h" | 38 | #include "fileitem.h" | ||
39 | #include "virtualfilesystem.h" | 39 | #include "virtualfilesystem.h" | ||
40 | #include "../krservices.h" | 40 | #include "../krservices.h" | ||
41 | #include "../JobMan/jobman.h" | 41 | #include "../JobMan/jobman.h" | ||
42 | 42 | | |||
43 | 43 | | |||
44 | FileSystemProvider::FileSystemProvider() : _defaultFileSystem(0), _virtFileSystem(0) {} | 44 | FileSystemProvider::FileSystemProvider() : _defaultFileSystem(nullptr), _virtFileSystem(nullptr) {} | ||
45 | 45 | | |||
46 | FileSystem *FileSystemProvider::getFilesystem(const QUrl &url, FileSystem *oldFilesystem) | 46 | FileSystem *FileSystemProvider::getFilesystem(const QUrl &url, FileSystem *oldFilesystem) | ||
47 | { | 47 | { | ||
48 | const FileSystem::FS_TYPE type = getFilesystemType(url); | 48 | const FileSystem::FS_TYPE type = getFilesystemType(url); | ||
49 | return oldFilesystem && oldFilesystem->type() == type ? oldFilesystem : createFilesystem(type); | 49 | return oldFilesystem && oldFilesystem->type() == type ? oldFilesystem : createFilesystem(type); | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | void FileSystemProvider::startCopyFiles(const QList<QUrl> &urls, const QUrl &destination, | 52 | void FileSystemProvider::startCopyFiles(const QList<QUrl> &urls, const QUrl &destination, | ||
Show All 33 Lines | 77 | { | |||
86 | 86 | | |||
87 | QString mountPoint = ""; | 87 | QString mountPoint = ""; | ||
88 | if (directory.isLocalFile()) { | 88 | if (directory.isLocalFile()) { | ||
89 | KMountPoint::Ptr kMountPoint = KMountPoint::currentMountPoints().findByPath(directory.path()); | 89 | KMountPoint::Ptr kMountPoint = KMountPoint::currentMountPoints().findByPath(directory.path()); | ||
90 | if (kMountPoint) | 90 | if (kMountPoint) | ||
91 | mountPoint = kMountPoint->mountPoint(); | 91 | mountPoint = kMountPoint->mountPoint(); | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | for(QPointer<FileSystem> fileSystemPointer: _fileSystems) { | 94 | for(const QPointer<FileSystem>& fileSystemPointer: _fileSystems) { | ||
95 | FileSystem *fs = fileSystemPointer.data(); | 95 | FileSystem *fs = fileSystemPointer.data(); | ||
96 | // refresh all filesystems currently showing this directory | 96 | // refresh all filesystems currently showing this directory | ||
97 | // and always refresh filesystems showing a virtual directory; it can contain files from | 97 | // and always refresh filesystems showing a virtual directory; it can contain files from | ||
98 | // various places, we don't know if they were (re)moved. Refreshing is also fast enough. | 98 | // various places, we don't know if they were (re)moved. Refreshing is also fast enough. | ||
99 | const QUrl fileSystemDir = fs->currentDirectory(); | 99 | const QUrl fileSystemDir = fs->currentDirectory(); | ||
100 | if ((!fs->hasAutoUpdate() && (fileSystemDir == FileSystem::cleanUrl(directory) || | 100 | if ((!fs->hasAutoUpdate() && (fileSystemDir == FileSystem::cleanUrl(directory) || | ||
101 | (fs->type() == FileSystem::FS_VIRTUAL && !fs->isRoot()))) | 101 | (fs->type() == FileSystem::FS_VIRTUAL && !fs->isRoot()))) | ||
102 | // also refresh if a parent directory was (re)moved (not detected by file watcher) | 102 | // also refresh if a parent directory was (re)moved (not detected by file watcher) | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
171 | #endif | 171 | #endif | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | QString FileSystemProvider::getACL(const QString & path, int type) | 174 | QString FileSystemProvider::getACL(const QString & path, int type) | ||
175 | { | 175 | { | ||
176 | Q_UNUSED(path); | 176 | Q_UNUSED(path); | ||
177 | Q_UNUSED(type); | 177 | Q_UNUSED(type); | ||
178 | #ifdef HAVE_POSIX_ACL | 178 | #ifdef HAVE_POSIX_ACL | ||
179 | acl_t acl = 0; | 179 | acl_t acl = nullptr; | ||
180 | // do we have an acl for the file, and/or a default acl for the dir, if it is one? | 180 | // do we have an acl for the file, and/or a default acl for the dir, if it is one? | ||
181 | if ((acl = acl_get_file(path.toLocal8Bit(), type)) != 0) { | 181 | if ((acl = acl_get_file(path.toLocal8Bit(), type)) != nullptr) { | ||
182 | bool aclExtended = false; | 182 | bool aclExtended = false; | ||
183 | 183 | | |||
184 | #ifdef HAVE_NON_POSIX_ACL_EXTENSIONS | 184 | #ifdef HAVE_NON_POSIX_ACL_EXTENSIONS | ||
185 | aclExtended = acl_equiv_mode(acl, 0); | 185 | aclExtended = acl_equiv_mode(acl, 0); | ||
186 | #else | 186 | #else | ||
187 | acl_entry_t entry; | 187 | acl_entry_t entry; | ||
188 | int ret = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry); | 188 | int ret = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry); | ||
189 | while (ret == 1) { | 189 | while (ret == 1) { | ||
190 | acl_tag_t currentTag; | 190 | acl_tag_t currentTag; | ||
191 | acl_get_tag_type(entry, ¤tTag); | 191 | acl_get_tag_type(entry, ¤tTag); | ||
192 | if (currentTag != ACL_USER_OBJ && | 192 | if (currentTag != ACL_USER_OBJ && | ||
193 | currentTag != ACL_GROUP_OBJ && | 193 | currentTag != ACL_GROUP_OBJ && | ||
194 | currentTag != ACL_OTHER) { | 194 | currentTag != ACL_OTHER) { | ||
195 | aclExtended = true; | 195 | aclExtended = true; | ||
196 | break; | 196 | break; | ||
197 | } | 197 | } | ||
198 | ret = acl_get_entry(acl, ACL_NEXT_ENTRY, &entry); | 198 | ret = acl_get_entry(acl, ACL_NEXT_ENTRY, &entry); | ||
199 | } | 199 | } | ||
200 | #endif | 200 | #endif | ||
201 | 201 | | |||
202 | if (!aclExtended) { | 202 | if (!aclExtended) { | ||
203 | acl_free(acl); | 203 | acl_free(acl); | ||
204 | acl = 0; | 204 | acl = nullptr; | ||
205 | } | 205 | } | ||
206 | } | 206 | } | ||
207 | 207 | | |||
208 | if (acl == 0) | 208 | if (acl == nullptr) | ||
209 | return QString(); | 209 | return QString(); | ||
210 | 210 | | |||
211 | char *aclString = acl_to_text(acl, 0); | 211 | char *aclString = acl_to_text(acl, nullptr); | ||
212 | QString ret = QString::fromLatin1(aclString); | 212 | QString ret = QString::fromLatin1(aclString); | ||
213 | acl_free((void*)aclString); | 213 | acl_free((void*)aclString); | ||
214 | acl_free(acl); | 214 | acl_free(acl); | ||
215 | 215 | | |||
216 | return ret; | 216 | return ret; | ||
217 | #else | 217 | #else | ||
218 | return QString(); | 218 | return QString(); | ||
219 | #endif | 219 | #endif | ||
220 | } | 220 | } |