Our atomic write involves writing a temp file and renaming that (which is
the only way to achieve something atomic). This creates a new inode, and
disconnects any hardlinks.
Note that the existing implementation for file paths with needsDevice
already keeps hardlinks intact, because even though it first writes into
a local temporary file it then writes the content directly into the
target with dd.
Check the number of hard links via system API and fallback to unsafe
writing if there are any, for desktop paths.
Fixes: QTCREATORBUG-19651
Change-Id: I3ce1ee81f339f241f0a2c9aa6f2259cb118ebef6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Basically a.onDevice(b) == b.withNewMappedPath(a), matching the order
of b.withNewPath(a).
Whether the (curretly docker-specific) path mapping is useful /there/, and
whether some of the calls are needed at all is dubious. I added some
FIXME and changed a few cases directly.
Change-Id: I7514736ce922f632f1f737bc496f6783389a42b6
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
ensureWriteableDir() and createDir()
Also change a few \returns to Returns.
Change-Id: I8c80616a465a7e665ff56fab8279e43e5755fb4f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Passing mandatory context object clearly suggests a special
care should be taken for assuring the passed function
may still run when the task finishes in the future.
Fix FileStreamManager so that it deletes the streamer
even when context object was deleted in meantime.
Fix 2 usages of asyncCopy so that we pass a context object now.
Side note: passing nullptr as a context object is still
possible and should work, but it's not recommended.
Change-Id: I464438db42ed9292c2f89ecb9d5dde7c78f77640
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Also move some often used types into new file "utiltypes.h"
Change-Id: I3f152d1dc2f96ba0259ad6c098d9ac5ee03a59f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Moves all tests that are applicable only to FilePath over from
tst_fileutils.
Change-Id: Ic331e1470a7479ee2f8ba38baec84124982a000a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Previously the "fileName" of every device inside a scheme subfolder
would be empty. Therefore QDirIterator would skip them.
Change-Id: Ifa46859aadbd8a81364a1fe0a72b9a50a7a396ca
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
FilePath::hasFileAccess allows a user to test if a specific device
can access files. This is faster than calling "exists()" as it does
not have to actually check anything on the device.
Task-number: QTCREATORBUG-28531
Change-Id: I94b5b9e0ae020b81f126c61fd06bb25f3d4a88cb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Specifies the main purpose more clearly. The remaining ones a "true"
(internal) variants in models and as action data.
Change-Id: I8dd3c846e419f29d88283c2f48268ef6685b19fe
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Previously anytime a FilePath operation tried to access a device that
does not have a DeviceFileAccess an error message would be thrown.
This patch makes it possible to differentiate between the device not
being found, and the device just not having a DeviceFileAccess
interface.
Also the error message in DeviceFileAccess::exists() was removed as
its not an error to ask if something exists even if it does not.
Change-Id: Ib8c2e08132159d0d97bcd049b59436eb17bdbacd
Reviewed-by: hjk <hjk@qt.io>
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...
While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only
Change was done by running
find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;
Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
The distiction relative/absolute path is not broad enough to
cover all situations like e.g. Windows paths with drive letter
but not starting with backslash, and generally also rarely needed
in user code. The situation doesn't get better with "convenience
defaults", like empty path meaning depending on context.
Mid-term I'd like to ramp down uses in user code, moving corner-case
handling to filepath.cpp behind "higher level" FilePath API.
This here is one step towards this goal.
Change-Id: I070112810a1628ced035e90cc7dc679e2248d688
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
FilePath::localSource can return a filepath that represents a local version
of a remote file.
It is used to let the debugger select the local version of a file when
debugging a remote target.
Change-Id: Ieb934ef0d454e8ff55e71df41dca825974d85da7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
Adds a std::expected implementation that is compatible with >= C++11.
FilePath::fileContents and FilePath::writeFileContents as well as
FilePath::copyFile are changed to return std::expected.
A couple of macros have been added to aid in using the expected types.
An auto test was added showing how to use the library.
Change-Id: Ibe3aecfc1029a0cf13b45bf5184ff03a04a2393b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Even though the concepts are similar, direct conversion is
usually neither desired (lossy) nor needed.
Change-Id: Id5c9e69d0597ed867cbda25f3fc4619a9fe90966
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>