Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6de16604 authored by kyle_tso's avatar kyle_tso
Browse files

Add support of directory copy



When copying directories, files and sub-directories should be
recursively copied. And we have to update the database by scanning
the entire directory.

Test: Copy directories with sub-directories and files inside to
another location. All directories and files are successfully
copied.

Change-Id: Iea9603b51bd0a944c87dedd962804d18d11984c4
Signed-off-by: default avatarkyle_tso <kyle_tso@htc.com>
parent 289cce60
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ public:
                                            MtpObjectFormat format,
                                            bool succeeded) = 0;

    virtual void                    doScanDirectory(const char* path) = 0;

    virtual MtpObjectHandleList*    getObjectList(MtpStorageID storageID,
                                            MtpObjectFormat format,
                                            MtpObjectHandle parent) = 0;
+3 −0
Original line number Diff line number Diff line
@@ -1148,6 +1148,7 @@ MtpResponseCode MtpServer::doCopyObject() {
    ALOGV("Copying file from %s to %s", (const char*)fromPath, (const char*)path);
    if (format == MTP_FORMAT_ASSOCIATION) {
        int ret = makeFolder((const char *)path);
        ret += copyRecursive(fromPath, path);
        if (ret) {
            result = MTP_RESPONSE_GENERAL_ERROR;
        }
@@ -1158,6 +1159,8 @@ MtpResponseCode MtpServer::doCopyObject() {
    }

    mDatabase->endSendObject(path, handle, format, result);
    if (format == MTP_FORMAT_ASSOCIATION)
        mDatabase->doScanDirectory(path);
    mResponse.setParameter(1, handle);
    return result;
}