Reputation: 1105
I am looking for a cross-platform way of opening file in a way that other applications can read and write into it. The Windows's API has this functionality: http://msdn.microsoft.com/en-us/library/y973b725(v=vs.110).aspx ( FileShare parameter )
Is there any way this to be done with QT in a cross-platform fashion.
Thanks:)
Upvotes: 3
Views: 1890
Reputation: 9754
App is cross-platform or you need access cross-platform machines?
Unfortunately I found no "source" that is "cross-platform" for this task, I can refer you to is a way to access windows machines (or supporting samba).
#include <QMessageBox>
...
QString file;
#ifdef Q_OS_LINUX
//app compiled in Linux (requires samba)
file = "smb://PC/folder/file.txt";
#endif
#ifdef Q_OS_WIN32
//app compiled in Windows (x86)
file = "\\\\PC\\folder\\file.txt"; // "\\PC\FOLDER\filer.txt"
#endif
QFile test(file);
if (test.exists()){
QMessageBox::about(NULL, "1", "exists");
} else {
QMessageBox::about(NULL, "1", "not exists");
}
defines for differents platforms:
Q_OS_DARWIN64
Q_OS_DARWIN32
Q_OS_ANDROID
Q_OS_LINUX
Q_OS_CYGWIN
Q_OS_WIN32
Q_OS_WIN64
Q_OS_WINCE
Q_OS_WINPHONE
Q_OS_WINRT
Q_OS_SOLARIS
Q_OS_HPUX
Q_OS_ULTRIX
Q_OS_RELIANT
Q_OS_NACL
Q_OS_FREEBSD
Q_OS_FREEBSD_KERNEL
Q_OS_BSD4
Q_OS_NETBSD
Q_OS_OPENBSD
Q_OS_BSDI
Q_OS_IRIX
Q_OS_OSF
Q_OS_AIX
Q_OS_LYNX
Q_OS_HURD
Q_OS_DGUX
Q_OS_QNX
Q_OS_DYNIX
Q_OS_SCO
Q_OS_UNIXWARE
Q_OS_INTEGRITYQ_OS_VXWORKS
I can let you know is that you will have to detect open "ports" on the machine (test it), access is by the "ports".
Upvotes: 2