|
|
Net Transparency, formerly provided by kfmlib, but now done with KIO::Jobs.
This class isn't meant to be used as a class but only as a simple
namespace for static functions, though an instance of the class
is built for internal purposes. Whereas a kiojob
is
asynchronous, meaning that the developer has to connect slots
for it, KIO::NetAccess
provides synchronous downloads and
uploads, as well as temporary file creation and removal.
Port to kio done by David Faure, faure@kde.org
bool |
[static]
Download a file from an arbitrary URL (src)
to a
temporary file on the local filesystem (target).
If the argument
for target
is an empty string, download will generate a
unique temporary filename in /tmp. Since target
is a reference
to QString you can access this filename easily. Download will
return true
if the download was successful, otherwise false.
Special case:
If the URL is of kind file:
then no downloading is
processed but the full filename is returned in target.
That means you have to take care about the target
argument.
(This is very easy to do, please see the example below.)
Download is synchronous. That means you can use it like
this, (assuming u
is a string which represents a URL and your
application has a loadFile() function):
QString tmpFile; if( KIO::NetAccess::download( u, tmpFile ) ) { loadFile( tmpFile ); KIO::NetAccess::removeTempFile( tmpFile ); } |
Of course, your user interface will still process exposure/repaint events during the download.
Parameters:
void |
[static]
Remove the specified file if and only if it was created by KIO::NetAccess as a temporary file for a former download.
Note: This means that if you created your temporary with KTempFile, use KTempFile::unlink() or KTempFile::setAutoDelete() to have it removed.
Parameters:
bool |
[static]
Upload file src
to URL target.
Both must be specified, unlike download. Note that this is assumed to be used for saving a file over the network, so overwriting is set to true. This is not the case with copy.
Parameters:
bool |
[static]
Alternative method for copying over the network.
Overwrite is false, so this will fail if target
exists.
This one takes two URLs and is a direct equivalent of KIO::file_copy (not KIO::copy!).
bool |
[static]
Test whether a URL exists.
This is a convenience function for KIO::stat (it saves creating a slot and testing for the job result).
Parameters:
bool |
[static]
Test whether a URL exists and return information on it.
This is a convenience function for KIO::stat (it saves creating a slot and testing for the job result).
Parameters:
bool |
[static]
Delete a file or a directory in an synchronous way.
This is a convenience function for KIO::del (it saves creating a slot and testing for the job result).
Parameters:
Returns: true
on success, false
on failure.
bool |
[static]
Create a directory in an synchronous way.
This is a convenience function for KIO::mkdir
(it saves creating a slot and testing for the job result).
Parameters:
Returns: true
on success, false
on failure.
QString |
[static]
Determine the mimetype of a given URL.
This is a convenience function for KIO::mimetype. You should call this only when really necessary. KMimeType::findByURL can determine extension a lot faster, but less reliably for remote files. Only when findByURL() returns unknown (application/octet-stream) then this one should be used.
Parameters:
Returns: The mimetype name.
QString |
[static]
Return error string for the last job, in case it failed
Generated by: prospector@porky.devel.redhat.com on Fri Nov 3 09:58:58 2000, using kdoc 2.0a42. |