Find out whether a file is a remote file or not

Dominik Haumann dhaumann at kde.org
Sun May 1 17:12:11 UTC 2016


On Sun, May 1, 2016 at 6:28 PM, Dominik Haumann <dhaumann at kde.org> wrote:
> Hi all,
>
> do we have a mechanism in KDE to find out whether a file is a truly
> local file, or a remote file?
>
> With remote file I mean e.g. a sshfs mounted location that appears in
> the file system, which integrates seamlessly into the local
> filesystem, but in truth, it is not a local file.
>
> As initial start, I'd consider local disks and plugged in USB sticks
> local, everything else remote.
>
> In Kate, we typically backup local files, and maybe "worse", by
> default create swap files for local files. But given that remotely
> mounted filesystem also appear as local files, this leads to a
> potential bottleneck.
>
> BUG: https://bugs.kde.org/show_bug.cgi?id=362288
>
> CC: Vishesh, since maybe baloo also had to solve these issues


What I have found:

KIO contains [1] KMountPoint::probablySlow(), and it's returning true
for nfs, cifs, and some others, but not for e.g. sshfs, see [2]. So
this is not exactly what I want, or at least, it would need extension.

PS: The implementation of [2] could be much faster, given it first
computes all bools, and only then checks them.

Anyways, using this, it would look similar to this:

KMountPoint::List mountedDeviceList = KMountPoint::currentMountPoints();
KMountPoint::Ptr mountPoint =
mountedDeviceList->findByDevice(kateDocument()->url());
if (mountPoint && mountPoint->isProbablySlow()) {
    // disalbe swap file and backups
}

Is that the suggested solution, or is there a better way?

Cheers,
Dominik

[1] http://api.kde.org/frameworks-api/apidox-frameworks/frameworks5-apidocs/kio/html/classKMountPoint.html#a338731f8ed1c8b02b317da32857aa198
[2] http://api.kde.org/frameworks-api/apidox-frameworks/frameworks5-apidocs/kio/html/kmountpoint_8cpp_source.html#l00535


More information about the Kde-frameworks-devel mailing list