Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

implement symlink().

  • Loading branch information...
commit acd02ec8ea0063c989fa55afd9a7f1ba74e15fb1 1 parent b443c08
@JonathanBeck authored
Showing with 63 additions and 2 deletions.
  1. +30 −2 afcdevice.cpp
  2. +1 −0  afcdevice.h
  3. +32 −0 kio_afc.cpp
View
32 afcdevice.cpp
@@ -583,8 +583,6 @@ bool AfcDevice::del( const QString& path, KIO::Error& error)
bool AfcDevice::rename( const QString& src, const QString& dest, KIO::JobFlags flags, KIO::Error& error )
{
- char off_t_should_be_64_bits[sizeof(off_t) >= 8 ? 1 : -1]; (void) off_t_should_be_64_bits;
-
//make sure path exists
UDSEntry entry_src;
if ( !createUDSEntry("", src, entry_src, error) )
@@ -612,3 +610,33 @@ bool AfcDevice::rename( const QString& src, const QString& dest, KIO::JobFlags f
return checkError(er, error);
}
+
+bool AfcDevice::symlink( const QString& src, const QString& dest, KIO::JobFlags flags, KIO::Error& error )
+{
+ //make sure path exists
+ UDSEntry entry_src;
+ if ( !createUDSEntry("", src, entry_src, error) )
+ {
+ return false;
+ }
+
+ UDSEntry entry_dest;
+ if ( createUDSEntry("", dest, entry_dest, error) )
+ {
+ if (S_ISDIR( entry_dest.numberValue(UDSEntry::UDS_FILE_TYPE ) ) )
+ {
+ error = KIO::ERR_DIR_ALREADY_EXIST;
+ return false;
+ }
+
+ if (!(flags & KIO::Overwrite))
+ {
+ error = KIO::ERR_FILE_ALREADY_EXIST;
+ return false;
+ }
+ }
+
+ afc_error_t er = afc_make_link ( _afc, AFC_SYMLINK, (const char*) src.toLocal8Bit(), (const char*) dest.toLocal8Bit() );
+
+ return checkError(er, error);
+}
View
1  afcdevice.h
@@ -51,6 +51,7 @@ class AfcDevice
bool del( const QString& path, KIO::Error& error);
bool rename( const QString& src, const QString& dest, KIO::JobFlags flags, KIO::Error& error );
+ bool symlink( const QString& src, const QString& dest, KIO::JobFlags flags, KIO::Error& error );
private:
View
32 kio_afc.cpp
@@ -276,6 +276,38 @@ void AfcProtocol::symlink( const QString &target, const KUrl &dest,
KIO::JobFlags flags )
{
kDebug(KIO_AFC) << target << "to " << dest;
+
+ // check (correct) URL
+ const AfcPath path_dest = checkURL(dest);
+
+ //make sue we are on the same device
+
+ if ( target.contains( path_dest.m_host, Qt::CaseSensitive ) )
+ {
+ AfcDevice* device = _devices[path_dest.m_host];
+
+ if ( NULL == device )
+ {
+ error(KIO::ERR_DOES_NOT_EXIST, "Could not find specified device");
+ return;
+ }
+
+ QString src = target;
+ src.remove("/" + path_dest.m_host, Qt::CaseSensitive );
+
+ KIO::Error err;
+ if ( ! device->symlink(src, path_dest.m_path, flags, err ) )
+ {
+ error(err, target);
+ return;
+ }
+ }
+ else
+ {
+ error ( KIO::ERR_CANNOT_SYMLINK, "Cannot symlink on different device");
+ return;
+ }
+ finished();
}
Please sign in to comment.
Something went wrong with that request. Please try again.